Practice the basic operation of the Matrix: O (∩_∩) o~
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceconsoleapplication4{classMyMatrix3 {intM11, M12, M13; intM21, M22, M23; intM31, M32, M33; //Matrix addition PublicMyMatrix3 AddMatrix3 (MyMatrix3 m1,mymatrix3 m2) {MyMatrix3 newMatrix3=NewMyMatrix3 (); NEWMATRIX3.M11= M1.m11 +M2.m11; NEWMATRIX3.M12= M1.m12 +M2.m12; Newmatrix3.m13= M1.m13 +M2.m13; Newmatrix3.m21= M1.m21 +M2.m21; NEWMATRIX3.M22= M1.m22 +M2.m22; NEWMATRIX3.M23= M1.m23 +m2.m23; NEWMATRIX3.M31= M1.m31 +M2.m31; Newmatrix3.m32= M1.m32 +M2.m32; Newmatrix3.m33= M1.m33 +M2.m33; returnnewMatrix3; } //Matrix addition PublicMyMatrix3 SubMatrix3 (MyMatrix3 M1, MyMatrix3 m2) {MyMatrix3 newMatrix3=NewMyMatrix3 (); NEWMATRIX3.M11= M1.m11-M2.m11; NEWMATRIX3.M12= M1.m12-M2.m12; Newmatrix3.m13= M1.m13-M2.m13; Newmatrix3.m21= M1.m21-M2.m21; NEWMATRIX3.M22= M1.m22-M2.m22; NEWMATRIX3.M23= M1.M23-m2.m23; NEWMATRIX3.M31= M1.m31-M2.m31; Newmatrix3.m32= M1.m32-M2.m32; Newmatrix3.m33= M1.m33-M2.m33; returnnewMatrix3; } //matrix and scalar multiplication PublicMyMatrix3 scalarmultiply (MyMatrix3 A,intScale ) {MyMatrix3 newMatrix3=NewMyMatrix3 (); NEWMATRIX3.M11= A.m11 *Scale ; NEWMATRIX3.M12= A.m12 *Scale ; NEWMATRIX3.M12= A.m12 *Scale ; Newmatrix3.m21= A.m21 *Scale ; NEWMATRIX3.M22= A.m22 *Scale ; NEWMATRIX3.M23= A.M23 *Scale ; Newmatrix3.m21= A.m21 *Scale ; NEWMATRIX3.M22= A.m22 *Scale ; NEWMATRIX3.M23= A.M23 *Scale ; returnnewMatrix3; } //matrix multiplication PublicMyMatrix3 ScalarMatrix3 (MyMatrix3 a,mymatrix3 b) {MyMatrix3 newMatrix3=NewMyMatrix3 (); NEWMATRIX3.M11= A.m11 * B.M11 + a.m12 * b.m21 + a.m13 *B.m31; NEWMATRIX3.M12= A.m11 * B.M12 + a.m12 * B.M22 + a.m13 *B.m32; Newmatrix3.m13= A.m11 * b.m13 + a.m12 * b.m23 + a.m13 *B.m33; Newmatrix3.m21= A.m21 * B.M11 + a.m22 * b.m21 + a.m23 *B.m31; NEWMATRIX3.M22= A.m21 * B.M12 + a.m22 * B.M22 + a.m23 *B.m32; NEWMATRIX3.M23= A.m21 * b.m13 + a.m22 * b.m23 + a.m23 *B.m33; NEWMATRIX3.M31= A.m31 * B.M11 + a.m32 * b.m21 + a.m33 *B.m31; Newmatrix3.m32= A.m31 * B.M12 + a.m32 * B.M22 + a.m33 *B.m32; Newmatrix3.m33= A.m31 * b.m13 + a.m32 * b.m23 + a.m33 *B.m33; returnnewMatrix3; } }}
Matrix operations Add, subtract, multiply scalar, multiply