/// <summary> /// operate--> /// </summary> public static MyMat mul(MyMat left, MyMat right) { if (left.cols == 0 || left.rows == 0 || right.cols == 0 || right.rows == 0) { Debug.Print(" MyMat mul : " + left.cols + " " + left.rows + " " + right.cols + " " + right.rows); return(MyMat.NULL()); } if (left.cols != right.rows) { Debug.Print(" MyMat mul : left.cols != right.rows"); return(MyMat.NULL()); } MyMat output = new MyMat(left.rows, right.cols); for (int i = 0; i < output.rows; i++) { for (int j = 0; j < output.cols; j++) { output[i, j] = 0; for (int k = 0; k < left.cols; k++) { output[i, j] += left[i, k] * right[k, j]; } } } return(output); }
public static MyMat MIRROR(double rad) { MyMat output = new MyMat(2, 2); output[0, 0] = Math.Cos(2 * rad); output[1, 0] = Math.Sin(2 * rad); output[0, 1] = output[1, 0]; output[1, 1] = -1.0 * output[0, 0]; return(output); }
public static MyMat ROTATE(double rad) { MyMat output = new MyMat(2, 2); output[0, 0] = Math.Cos(rad); output[1, 0] = Math.Sin(rad); output[0, 1] = -1.0 * output[1, 0]; output[1, 1] = output[0, 0]; return(output); }