I will explain how to write donut in any language
Let R2 = 2, R1 = 1
To multply it, instead of solving in manually or a matrix solver, we will create a struct (C/C++/Go) or class (Java/Python)
In C
typedef struct {
double a1;
double a2;
double a3;
} singleRow;
Modify according to your language and make sure all members are public
For java
class singleRow {
public double a1;
public double a2;
public double a3;
public singleRow(double a1, double a2, double a3) {
this.a1 = a1;
this.a2 = a2;
this.a3 = a3;
}
}
then a matrix struct/class and make all members public
In C
typedef struct {
singleRow a1;
singleRow a2;
singleRow a3;
} Matrix;
For java
class Matrix {
public singleRow a1;
public singleRow a2;
public singleRow a3;
public Matrix(singleRow a1, singleRow a2, singleRow a3) {
this.a1 = new singleRow(a1.a1, a1.a2, a1.a3);
this.a2 = new singleRow(a2.a1, a2.a2, a2.a3);
this.a3 = new singleRow(a3.a1, a3.a2, a3.a3);
}
}
Top comments (0)