/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix2D like2D(int rows, int columns) { return content.like2D(rows,columns); } /**
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix2D like2D(int rows, int columns) { return content.like2D(rows,columns); } /**
/** * Outer product of two vectors; Returns a matrix with <tt>A[i,j] = x[i] * y[j]</tt>. * * @param x the first source vector. * @param y the second source vector. * @return the outer product </tt>A</tt>. */ private DoubleMatrix2D xmultOuter(DoubleMatrix1D x, DoubleMatrix1D y) { DoubleMatrix2D A = x.like2D(x.size(),y.size()); multOuter(x,y,A); return A; } /**
/** * Outer product of two vectors; Returns a matrix with <tt>A[i,j] = x[i] * y[j]</tt>. * * @param x the first source vector. * @param y the second source vector. * @return the outer product </tt>A</tt>. */ private DoubleMatrix2D xmultOuter(DoubleMatrix1D x, DoubleMatrix1D y) { DoubleMatrix2D A = x.like2D(x.size(),y.size()); multOuter(x,y,A); return A; } /**
/** * Returns a string representation of the given matrix. * @param matrix the matrix to convert. */ public String toString(DoubleMatrix1D matrix) { DoubleMatrix2D easy = matrix.like2D(1,matrix.size()); easy.viewRow(0).assign(matrix); return toString(easy); } /**
/** * Returns a string representation of the given matrix. * @param matrix the matrix to convert. */ public String toString(DoubleMatrix1D matrix) { DoubleMatrix2D easy = matrix.like2D(1,matrix.size()); easy.viewRow(0).assign(matrix); return toString(easy); } /**
/** * Outer product of two vectors; Sets <tt>A[i,j] = x[i] * y[j]</tt>. * * @param x the first source vector. * @param y the second source vector. * @param A the matrix to hold the results. Set this parameter to <tt>null</tt> to indicate that a new result matrix shall be constructed. * @return A (for convenience only). * @throws IllegalArgumentException if <tt>A.rows() != x.size() || A.columns() != y.size()</tt>. */ public DoubleMatrix2D multOuter(DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix2D A) { int rows = x.size(); int columns = y.size(); if (A==null) A = x.like2D(rows,columns); if (A.rows() != rows || A.columns() != columns) throw new IllegalArgumentException(); for (int row = rows; --row >= 0; ) A.viewRow(row).assign(y); for (int column = columns; --column >= 0; ) A.viewColumn(column).assign(x, cern.jet.math.Functions.mult); return A; } /**
/** * Outer product of two vectors; Sets <tt>A[i,j] = x[i] * y[j]</tt>. * * @param x the first source vector. * @param y the second source vector. * @param A the matrix to hold the results. Set this parameter to <tt>null</tt> to indicate that a new result matrix shall be constructed. * @return A (for convenience only). * @throws IllegalArgumentException if <tt>A.rows() != x.size() || A.columns() != y.size()</tt>. */ public DoubleMatrix2D multOuter(DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix2D A) { int rows = x.size(); int columns = y.size(); if (A==null) A = x.like2D(rows,columns); if (A.rows() != rows || A.columns() != columns) throw new IllegalArgumentException(); for (int row = rows; --row >= 0; ) A.viewRow(row).assign(y); for (int column = columns; --column >= 0; ) A.viewColumn(column).assign(x, cern.jet.math.Functions.mult); return A; } /**