|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixMathImpl<GivensMatrix>
com.numericalmethod.suanshu.matrix.doubles.matrixtype.GivensMatrix
public class GivensMatrix
Givens rotation is a rotation in the plane spanned by two coordinates axes.
That is, left multiplying a vector x by G(i, j, θ),
i.e., G(i, j, θ)x,
amounts to rotating x counter-clockwise by radians in the (i ,j) coordinate plane.
Its main use is to zero out entries in matrices and vectors.
Compared to Householder transformation, Givens rotation can zero out entries more selectively.
For instance, given a matrix A,
we can construct a Givens matrix, G, such that
GA has a 0 at an entry GA[i,j] of our choice.
Givens matrices are orthogonal.
Givens matrices are immutable.
| Constructor Summary | |
|---|---|
GivensMatrix(GivensMatrix that)
Copy constructor performing a deep copy. |
|
GivensMatrix(int dim,
int i,
int j,
double c,
double s)
Construct a Givens matrix of the form
| 1 ... 0 ... 0 ... 0 |
| |
|
| Method Summary | |
|---|---|
static GivensMatrix |
Ctor2x2(double c,
double s)
Construct GivensMatrix(2, 1, 2, c, s) |
static GivensMatrix |
CtorFromRho(int dim,
int i,
int j,
double rho)
Construct a Givens matrix from ρ. |
static GivensMatrix |
CtorToRotateColumns(int dim,
int col1,
int col2,
double a,
double b)
Construct a Givens matrix such that [a b] %*% G = [* 0]. |
static GivensMatrix |
CtorToRotateRows(int dim,
int row1,
int row2,
double a,
double b)
Construct a Givens matrix such that G %*% [a b]transpose = [* 0]transpose. |
static GivensMatrix |
CtorToZeroOutEntry(Matrix A,
int i,
int j)
Construct a Givens matrix such that G %*% A
has 0 in the A[i, j] entry. |
static GivensMatrix |
CtorToZeroOutEntryByTranspose(Matrix A,
int i,
int j)
Construct a Givens matrix such that Gtranspose %*% A
has 0 in the A[i, j] entry. |
GivensMatrix |
deepCopy()
The implementation can return an instance created from this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
double |
get(int row,
int col)
Get the matrix entry at [row, col]. |
Vector |
getColumn(int col)
Get a specified column as a vector. |
Vector |
getRow(int row)
Get a specified row as a vector. |
Matrix |
multiply(Matrix A)
Left multiplication by G, namely,
G %*% A
affects only the i-th and the j-th rows. |
Vector |
multiply(Vector v)
Right multiply this matrix, A by a vector. |
GivensMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix. |
static Matrix |
product(GivensMatrix[] Gs)
Given Givens matrices {Gi},
compute G, where
G = G1 %*% ... %*% G2 %*% Gn
|
double |
rho()
Get ρ as in Section 5.1.11 in Matrix Computations, 3rd edition, by Golub G. |
Matrix |
rightMultiply(Matrix A)
Right multiplication by G, namely,
A %*% G
affects only the i-th and the j-th columns. |
Vector |
rotate(Vector x)
Deprecated. Not supported yet. |
void |
set(int row,
int col,
double value)
Deprecated. GivensMatrix is immutable |
GivensMatrix |
t()
t(this)
Compute the transpose of this matrix. |
java.lang.String |
toString()
|
Matrix |
ZERO()
Deprecated. no zero matrix for GivensMatrix |
| Methods inherited from class com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixMathImpl |
|---|
add, call, getSample, minus, nCols, nRows, opposite, scaled, setColumn, setColumn, setRow, setRow |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GivensMatrix(int dim,
int i,
int j,
double c,
double s)
| 1 ... 0 ... 0 ... 0 |
| ... |
| 0 ... c ... s ... 0 |
G(i, j, c, s) = | ... |
| 0 ...-s ... c ... 0 |
| ... |
| 0 ... 0 ... 0 ... 1 |
We have,
G[i, i] = c (diagonal entry)
G[j, j] = c (diagonal entry)
G[i, j] = s
G[j, i] = -s
dim - the dimension of Gi - ij - jc - cs - spublic GivensMatrix(GivensMatrix that)
that - another GivensMatrix| Method Detail |
|---|
public static GivensMatrix CtorFromRho(int dim,
int i,
int j,
double rho)
This implements the discussion in
Section 5.1.11 in Matrix Computations, 3rd edition, by Golub G. H., van Loan C. F.
dim - i - ij - jrho - ρ
public static GivensMatrix Ctor2x2(double c,
double s)
GivensMatrix(2, 1, 2, c, s)
c - cs - s
public static GivensMatrix CtorToRotateRows(int dim,
int row1,
int row2,
double a,
double b)
G %*% [a b]transpose = [* 0]transpose.
This operation rotates rows row1 and row2 to make the entry in row row2 0.
This implements a variant of the numerically stable version in
Algorithm 1.6 in Matrix Algorithms Vol. 1 by G. W. Stewart
dim - the dimension of Grow1 - i as in A[i, i] = crow2 - j as in A[i, j] = sa - y as in [a b]transposeb - z as in [a b]transpose
G
public static GivensMatrix CtorToZeroOutEntry(Matrix A,
int i,
int j)
G %*% A
has 0 in the A[i, j] entry.
A - a matrixi - i as in A[i, j]j - j as in A[i, j]
public static GivensMatrix CtorToRotateColumns(int dim,
int col1,
int col2,
double a,
double b)
[a b] %*% G = [* 0].
This operation rotates columns col1 and col2 to make the entry in column col2 0.
dim - the dimension of Gcol1 - i as in A[i, i] = ccol2 - j as in A[i, j] = sa - y as in [a b]transposeb - z as in [a b]transpose
public static GivensMatrix CtorToZeroOutEntryByTranspose(Matrix A,
int i,
int j)
Gtranspose %*% A
has 0 in the A[i, j] entry.
A - a matrixi - i as in A[i, j]j - j as in A[i, j]
Gpublic double rho()
Section 5.1.11 in Matrix Computations, 3rd edition, by Golub G. H., van Loan C. F.
@Deprecated public Vector rotate(Vector x)
x in the (i ,j) coordinate plane.
x - a vector
G(i, j, θ)x
public double get(int row,
int col)
MatrixAccessor[row, col].
row - the row indexcol - the column index
A[row, col]
public Vector getRow(int row)
throws MatrixAccessException
MatrixAccessor
getRow in interface MatrixAccessorgetRow in class MatrixMathImpl<GivensMatrix>row - the row index
A[row, ]
MatrixAccessException - when row < 1, or when row > number of rows
public Vector getColumn(int col)
throws MatrixAccessException
MatrixAccessor
getColumn in interface MatrixAccessorgetColumn in class MatrixMathImpl<GivensMatrix>col - the column index
A[, col]
MatrixAccessException - when col < 1, or when col > number of columnspublic GivensMatrix t()
MatrixRingt(this)
Compute the transpose of this matrix. The original matrix does not change. The returned value is independent and can be modified anyhow.
This is the involution on the matrix ring.
t in interface MatrixRingt in class MatrixMathImpl<GivensMatrix>public Matrix multiply(Matrix A)
G, namely,
G %*% A
affects only the i-th and the j-th rows.
That is,
[i-th row, j-th row]transpose = G %*% [i-th row, j-th row]transpose
multiply in interface Monoid<Matrix>multiply in interface MatrixRingmultiply in class MatrixMathImpl<GivensMatrix>A - left multiply matrix
G %*% Apublic Vector multiply(Vector v)
MatrixA by a vector.
multiply in interface Matrixmultiply in class MatrixMathImpl<GivensMatrix>v - a vector
A %*% vpublic Matrix rightMultiply(Matrix A)
G, namely,
A %*% G
affects only the i-th and the j-th columns.
That is,
[i-th column, j-th column] = [i-th column, j-th column] %*% G
A - left multiply matrix
A %*% Gpublic static Matrix product(GivensMatrix[] Gs)
{Gi},
compute G, where
G = G1 %*% ... %*% G2 %*% Gn
Gs - an array of Givens matrices
Gpublic GivensMatrix ONE()
MatrixRingFor a non-square matrix, it zeros out the rows (columns) with index > nCols (nRows).
public java.lang.String toString()
toString in class MatrixMathImpl<GivensMatrix>public GivensMatrix deepCopy()
Matrixthis by the copy
constructor of the class, or just this if the instance itself is
immutable.
Override the return type.
Matrix instance
@Deprecated
public void set(int row,
int col,
double value)
MatrixAccessor[row, col] to value.
This is the only method that may change the entries of a matrix.
row - the row indexcol - the column indexvalue - the value to set A[row, col] to@Deprecated public Matrix ZERO()
AbelianGroupa in the group,
the equation 0 + a = a + 0 = a holds.
0
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||