/** * */ protected int m() { return LU.rows(); } /**
public double operations() { // Mflops double m = A.rows(); double n = A.columns(); //double p = B.columns(); return 2.0*m*n / 1.0E6; } };
public double operations() { // Mflops double m = A.rows(); double n = A.columns(); return m*(n*n + n) / 1.0E6; } };
/** * The number of operations a single call to "apply" involves. */ public double operations() { return A.rows()*A.columns() / 1.0E6; } /**
public double operations() { // Mflops double n = A.columns(); double m = A.rows(); return 10.0 * m*n / 1.0E6; } };
/** * A matrix <tt>A</tt> is <i>square</i> if it has the same number of rows and columns. */ public boolean isSquare(DoubleMatrix2D A) { return A.rows() == A.columns(); } /**
public double operations() { // Mflops double n = A.columns(); double m = A.rows(); return 6.0 * m*n / 1.0E6; } };
public double operations() { // Mflops double m = A.rows(); double n = A.columns(); //double p = B.columns(); return 2.0*m*n / 1.0E6; } };
/** * Returns the sum of the diagonal elements of matrix <tt>A</tt>; <tt>Sum(A[i,i])</tt>. */ public double trace(DoubleMatrix2D A) { double sum = 0; for (int i=Math.min(A.rows(),A.columns()); --i >= 0;) { sum += A.getQuick(i,i); } return sum; } /**
/** * Checks whether the given matrix <tt>A</tt> is <i>square</i>. * @throws IllegalArgumentException if <tt>A.rows() != A.columns()</tt>. */ public void checkSquare(DoubleMatrix2D A) { if (A.rows() != A.columns()) throw new IllegalArgumentException("Matrix must be square: "+cern.colt.matrix.doublealgo.Formatter.shape(A)); } /**
/** * Returns the infinity norm of matrix <tt>A</tt>, which is the maximum absolute row sum. */ public double normInfinity(DoubleMatrix2D A) { double max = 0; for (int row = A.rows(); --row >=0; ) { //max = Math.max(max, normInfinity(A.viewRow(row))); max = Math.max(max, norm1(A.viewRow(row))); } return max; } /**
public double operations() { // Mflops double m = A.rows(); double n = A.columns(); double p = B.columns(); return 2.0*m*n*p / 1.0E6; } };
public double operations() { // Mflops double m = A.rows(); double n = A.columns(); double p = B.columns(); return 2.0*m*n*p / 1.0E6; } };
/** * A square matrix <tt>A</tt> is <i>orthogonal</i> if <tt>A*transpose(A) = I</tt>. * @throws IllegalArgumentException if <tt>!isSquare(A)</tt>. */ public boolean isOrthogonal(DoubleMatrix2D A) { checkSquare(A); return equals(A.zMult(A,null,1,0,false,true), cern.colt.matrix.DoubleFactory2D.dense.identity(A.rows())); } /**
public void dger(double alpha, DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix2D A) { cern.jet.math.PlusMult fun = cern.jet.math.PlusMult.plusMult(0); for (int i=A.rows(); --i >= 0; ) { fun.multiplicator = alpha * x.getQuick(i); A.viewRow(i).assign(y,fun); } } public double dnrm2(DoubleMatrix1D x) {
public void dswap(DoubleMatrix2D A, DoubleMatrix2D B) { //B.swap(A); not yet implemented A.checkShape(B); for(int i = A.rows(); --i >= 0;) A.viewRow(i).swap(B.viewRow(i)); } public void dsymv(boolean isUpperTriangular, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) {
public void dswap(DoubleMatrix2D A, DoubleMatrix2D B) { //B.swap(A); not yet implemented A.checkShape(B); for(int i = A.rows(); --i >= 0;) A.viewRow(i).swap(B.viewRow(i)); } public void dsymv(boolean isUpperTriangular, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) {
/** * Solves A*X = B. * @return X; a new independent matrix; solution if A is square, least squares solution otherwise. */ public DoubleMatrix2D solve(DoubleMatrix2D A, DoubleMatrix2D B) { return (A.rows() == A.columns() ? (lu(A).solve(B)) : (qr(A).solve(B))); } /**
public void setParameters(DoubleMatrix2D G, DoubleMatrix2D H) { super.setParameters(G,H); D = new cern.colt.matrix.impl.DenseDoubleMatrix2D(A.rows(),A.columns()).assign(0.5); C = D.copy(); B = D.copy(); } public void init() { C.viewRow(0).assign(D.viewRow(0)); }
public void setParameters(DoubleMatrix2D G, DoubleMatrix2D H) { super.setParameters(G,H); D = new cern.colt.matrix.impl.DenseDoubleMatrix2D(A.rows(),A.columns()).assign(0.5); C = D.copy(); B = D.copy(); } public void init() { C.viewRow(0).assign(D.viewRow(0)); }