// divide method public static Arrayd operator /(Arrayd a, Arrayd b) { for (int m = 0; m < a.dims.Length; m++) { if (a.dims[m] != b.dims[m]) { throw new ArgumentException("Can not divide two arrayd with different element in some dimension.", nameof(a)); } } Arrayd ad = new Arrayd(); for (int i = 0; i < a.dims[0]; i++) { for (int j = 0; j < a.dims[1]; j++) { for (int k = 0; k < a.dims[2]; k++) { ad.arrayd[i, j, k] = a.arrayd[i, j, k] / b.arrayd[i, j, k]; } } } return(ad); }
// set ones method public static Arrayd Ones(Arrayd a) { for (int m = 0; m < a.dims.Length; m++) { if (a.dims[m] == 0) { throw new ArgumentException("Can not set arrayd to zeros in some dimension.", nameof(a.dims)); } } Arrayd ad = new Arrayd(); for (int i = 0; i < a.dims[0]; i++) { for (int j = 0; j < a.dims[1]; j++) { for (int k = 0; k < a.dims[2]; k++) { ad.arrayd[i, j, k] = 1.0f; } } } return(ad); }
// TODO: transpose // get the transpose method public static Arrayd Transpose(Arrayd a, int[] b) { for (int m = 0; m < a.dims.Length; m++) { if (a.dims[m] == 0) { throw new ArgumentException("Wrong arrayd, can not transpose arrayd with zero element in some dimension.", nameof(a)); } } Arrayd ad = new Arrayd(); return(ad); }
public static Arrayd operator /(Arrayd a, double b) { if (b.GetType() != typeof(double)) { throw new ArgumentException("Wrong number, the arrayd must divide double type number.", nameof(b)); } Arrayd ad = new Arrayd(); for (int i = 0; i < a.dims[0]; i++) { for (int j = 0; j < a.dims[1]; j++) { for (int k = 0; k < a.dims[2]; k++) { ad.arrayd[i, j, k] = a.arrayd[i, j, k] / b; } } } return(ad); }
// TODO: inverse // get the inverse method public static Arrayd Inverse(Arrayd a) { Arrayd ad = new Arrayd(); return(ad); }
// TODO: div public static Arrayd Div(Arrayd a, Arrayd b) { Arrayd ad = new Arrayd(); return(ad); }