public Matrix <T> Concat(Matrix <T> concatMatrix, int dim = 0) { var matchingDim = dim == 0 ? 1 : 0; if (this.Shape[matchingDim] != concatMatrix.Shape[matchingDim]) { throw new Exception(); } var concatShape = this.Shape.Copy(); concatShape[dim] = this.Shape[dim] + concatMatrix.Shape[dim]; var concat = new Matrix <T>(concatShape); MatrixExtensions.DoOperation(concat, this, x => x, true); var iStart = dim == 0 ? this.Shape.N : 0; var jStart = dim == 1 ? this.Shape.D : 0; MatrixExtensions.DoOperation(concat, concatMatrix, x => x, true, iStart, jStart); return(concat); }
public Matrix(int n, int d, T defaultValue) { init(n, d); MatrixExtensions.DoOperation(this, x => defaultValue, true); }
public static Matrix <T> operator /(Matrix <T> a, T x) { return(MatrixExtensions.DoOperation(a, i => (dynamic)i / x)); }
public static Matrix <T> operator *(T x, Matrix <T> a) { return(MatrixExtensions.DoOperation(a, i => (dynamic)i * x)); }
public static Matrix <T> operator -(Matrix <T> a, Matrix <T> b) { return(MatrixExtensions.DoOperation(a, b, (i, j) => (dynamic)i - j)); }