/// <summary> /// C = A||B; Constructs a new matrix which is the concatenation of two other matrices. /// </summary> /// <param name="a"> /// The matrix A. /// </param> /// <param name="b"> /// The matrix B. /// </param> /// <returns> /// The concatenation of A and B. /// </returns> public DoubleMatrix1D AppendColumns(DoubleMatrix1D a, DoubleMatrix1D b) { // concatenate DoubleMatrix1D matrix = Make(a.Size + b.Size); matrix.ViewPart(0, a.Size).Assign(a); matrix.ViewPart(a.Size, b.Size).Assign(b); return(matrix); }
/// <summary> /// Construct a matrix which is the concatenation of all given parts. /// Cells are copied. /// </summary> /// <param name="parts"> /// The parts. /// </param> /// <returns> /// A matrix. /// </returns> public DoubleMatrix1D Make(DoubleMatrix1D[] parts) { if (parts.Length == 0) { return(Make(0)); } int size = 0; for (int i = 0; i < parts.Length; i++) { size += parts[i].Size; } DoubleMatrix1D vector = Make(size); size = 0; for (int i = 0; i < parts.Length; i++) { vector.ViewPart(size, parts[i].Size).Assign(parts[i]); size += parts[i].Size; } return(vector); }
/// <summary> /// Constructs a new matrix which is A duplicated <tt>repeat</tt> times. /// </summary> /// <param name="a"> /// The matrix to duplicate. /// </param> /// <param name="repeat"> /// The number of repetitions. /// </param> /// <returns> /// A matrix. /// </returns> public DoubleMatrix1D Repeat(DoubleMatrix1D a, int repeat) { int size = a.Size; DoubleMatrix1D matrix = Make(repeat * size); for (int i = repeat; --i >= 0;) { matrix.ViewPart(size * i, size).Assign(a); } return(matrix); }