Class FhtKacRotator
- All Implemented Interfaces:
LinearOperator,VectorOperator
LinearOperator.
An orthogonal rotator conceptually is an orthogonal matrix that is applied to some vector x yielding a
new vector y that is rotated in some way along its n dimensions. Important to notice here is that such a
rotation preserves distances/lengths as well as angles between vectors.
Practically, we do not want to materialize such a rotator in memory as for n dimensions that would amount
to n^2 cells. In addition to that multiplying a matrix with a vector computationally is O(n^2) which
is prohibitively expensive for large n.
We also want to achieve some sort of randomness with these rotations. For small n, we can start by creating a
randomly generated matrix and decompose it using QR-decomposition into an orthogonal matrix Q and an upper
triangular matrix R. That matrix Q is indeed random (see matrix Haar randomness) and what we are
actually trying to find. For larger R this approach becomes impractical as Q needs to be represented
as a dense matrix which increases memory footprint and makes rotations slow (see above).
The main idea is to use several operators in conjunction:
Kwhich is orthogonal and applies several Givens rotation at once.D_nwhich are Random Rademacher diagonal sign matrices, i.e. matrices that are conceptually all0except for the diagonal which contains any combination-1,1. These matrices are also orthogonal. In particular, it flips only the signs of the elements of some other matrix when applied to it.Ha Hadamard matrix of a suitable size.
All these linear operators are combined in a way that we eventually compute the result of
x' = D1 H D_2 H ... D_(R-1) H D_(R) H K x
(for R rotations). None of these operators require a significant amount of memory (O(R * n) bits for signs).
They perform the complete rotation in O(R * (n log n)).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(RealVector x) Apply this operator to the vector passed in.computeP()Build dense P as double[n][n] (row-major).booleanintintinthashCode()booleanMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.apple.foundationdb.linear.LinearOperator
getNumDimensions, invertedApply, isSquareMethods inherited from interface com.apple.foundationdb.linear.VectorOperator
transform, untransform
-
Constructor Details
-
FhtKacRotator
public FhtKacRotator(long seed, int numDimensions, int rounds)
-
-
Method Details
-
getNumRowDimensions
public int getNumRowDimensions()- Specified by:
getNumRowDimensionsin interfaceLinearOperator
-
getNumColumnDimensions
public int getNumColumnDimensions()- Specified by:
getNumColumnDimensionsin interfaceLinearOperator
-
isTransposable
public boolean isTransposable()- Specified by:
isTransposablein interfaceLinearOperator
-
apply
Description copied from interface:VectorOperatorApply this operator to the vector passed in.- Specified by:
applyin interfaceVectorOperator- Parameters:
x- the vector- Returns:
- a new vector
-
transposedApply
- Specified by:
transposedApplyin interfaceLinearOperator
-
computeP
Build dense P as double[n][n] (row-major). This method exists for testing purposes only. -
equals
-
hashCode
public int hashCode()
-