public MatrixXD Concat(MatrixXD other, ConcatType concatType) { switch (concatType) { case ConcatType.Horizontal: { var totalCols = Cols + other.Cols; double[] inputValues = new double[Rows * totalCols]; var matrixXD = new MatrixXD(inputValues, Rows, totalCols); for (int i = 0; i < Rows; i++) { for (int j = 0; j < Cols; j++) { matrixXD.Set(i, j, Get(i, j)); } } int otherCols = other.Cols; for (int i = 0; i < other.Rows; i++) { for (int j = 0; j < otherCols; j++) { matrixXD.Set(i, Cols + j, other.Get(i, j)); } } return(matrixXD); } case ConcatType.Vertical: default: { int totalRows = Rows + other.Rows; double[] inputValues = new double[totalRows * Cols]; MatrixXD matrixXD = new MatrixXD(inputValues, totalRows, Cols); for (int i = 0; i < Rows; i++) { for (int j = 0; j < Cols; j++) { matrixXD.Set(i, j, Get(i, j)); } } int otherRows = other.Rows; for (int i = 0; i < otherRows; i++) { for (int j = 0; j < Cols; j++) { matrixXD.Set(Rows + i, j, other.Get(i, j)); } } return(matrixXD); } } }
private bool IsEqual(MatrixXD other) { if (Rows != other.Rows || Cols != other.Cols) { return(false); } return(ArrayHelpers.ArraysEqual(_values, other._values)); }
public MatrixXD Mult(MatrixXD other) { double[] outMatrix = new double[Rows * other.Cols]; EigenDenseUtilities.Mult(GetValues(), Rows, Cols, other.GetValues(), other.Rows, other.Cols, outMatrix); return(new MatrixXD(outMatrix, Rows, other.Cols)); }
public FullPivLUResult FullPivLU() { double[] l = new double[Rows * Rows]; double[] u = new double[Rows * Cols]; double[] p = new double[Rows * Rows]; double[] q = new double[Cols * Cols]; EigenDenseUtilities.FullPivLU(GetValues(), Rows, Cols, l, u, p, q); var L = new MatrixXD(l, Rows, Rows); L.SetDiag(1.0); return(new FullPivLUResult(L, new MatrixXD(u, Rows, Cols), new MatrixXD(p, Rows, Rows), new MatrixXD(q, Cols, Cols))); }
public MatrixXD Slice(int[] rows, int[] cols) { int nrows = rows.Length; int ncols = cols.Length; double[] inputValues = new double[nrows * ncols]; MatrixXD matrixXD = new MatrixXD(inputValues, nrows, ncols); for (int i = 0; i < nrows; i++) { for (int j = 0; j < ncols; j++) { matrixXD.Set(i, j, Get(rows[i], cols[j])); } } return(matrixXD); }
public MatrixXD(MatrixXD matrixXD) : base(matrixXD._values.ToArray(), matrixXD.Rows, matrixXD.Cols) { }