/// <summary> /// Copy the elements of the source array into the destination array, /// resizing if necessary. /// </summary> public void Copy <S>(Narray <S> src) { this.Resize(src.Dim(0), src.Dim(1), src.Dim(2), src.Dim(3)); index_t n = this.Length1d(); for (index_t i = 0; i < n; i++) { this.UnsafePut1d(i, src.UnsafeAt1d(i)); } }
public void Append <S>(Narray <S> src) { check_rank1(); Reserve(src.Length()); for (index_t i = 0; i < src.Length(); i++) { var value = src.UnsafeAt1d(i); data[dims[0]] = (T)Convert.ChangeType(value, typeof(T)); dims[0] += 1; total = dims[0]; } }
/// <summary> /// Copy the elements of the source array into the destination array, /// resizing if necessary. /// </summary> public void Append(Narray <T> src) { check_rank1(); Reserve(src.Length()); for (index_t i = 0; i < src.Length(); i++) { //Push(src.unsafe_at1d(i)); data[dims[0]] = src.UnsafeAt1d(i); dims[0] += 1; total = dims[0]; } }
public static void RowPush <T>(Narray <T> table, Narray <T> data) { if (table.Length1d() == 0) { table.Copy(data); table.Reshape(1, table.Length()); return; } CHECK_ARG(table.Dim(1) == data.Length(), "table.Dim(1) == data.Length()"); table.Reserve(table.Length1d() + data.Length()); table.SetDims(table.Dim(0) + 1, table.Dim(1), 0, 0); int irow = table.Dim(0) - 1; for (int k = 0; k < table.Dim(1); k++) { table[irow, k] = data.UnsafeAt1d(k); } }
/// <summary> /// Check whether two narrays are equal (mostly for testing). /// </summary> public bool Equal(Narray <T> b) { if (this.Rank() != b.Rank()) { return(false); } for (int i = 0; i < this.Rank(); i++) { if (this.Dim(i) != b.Dim(i)) { return(false); } } index_t n = this.Length1d(); for (index_t i = 0; i < n; i++) { if (!this.UnsafeAt1d(i).Equals(b.UnsafeAt1d(i))) { return(false); } } return(true); }