public static CMatrix operator *(CMatrix m1, CMatrix m2) { CMatrix multiplied = new CMatrix(m1.rows, m2.cols); for (int i = 0; i < m1.rows; i++) { for (int j = 0; j < m2.cols; j++) { //multiplied.Set(i, j, RowByCol( } } }
public static CMatrix operator -(CMatrix m) { CMatrix negative = new CMatrix(m.rows, m.cols); for (int i = 0; i < m.rows; i++) { for (int j = 0; j < m.cols; j++) { negative.Set(i, j, -m.Get(i, j)); } } return negative; }
public static CMatrix operator +(CMatrix m1, CMatrix m2) { CMatrix added = new CMatrix(m1.rows, m1.cols); for (int i = 0; i < m1.rows; i++) { for (int j = 0; j < m1.cols; j++) { added.Set(i, j, m1.Get(i, j) + m2.Get(i, j)); } } return added; }
public static CMatrix operator -(CMatrix m1, CMatrix m2) { CMatrix subbed = new CMatrix(m1.rows, m1.cols); for (int i = 0; i < m1.rows; i++) { for (int j = 0; j < m1.cols; j++) { subbed.Set(i, j, m1.Get(i, j) - m2.Get(i, j)); } } return subbed; }
public CMatrix Identity() { CMatrix identity = new CMatrix(rows, rows); for (int i = 0; i < rows; i++) { for (int j = 0; j < rows; j++) { if (i == j) { Set(i, j, 1.0f); } else { Set(i, j, 0.0f); } } } return identity; }