DEV Community

Jaipal001
Jaipal001

Posted on • Edited on

Explaining donut like 5 years old Part-1

I will explain how to write donut in any language

Let R2 = 2, R1 = 1

Image description

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;
Enter fullscreen mode Exit fullscreen mode

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;
  }
}
Enter fullscreen mode Exit fullscreen mode

then a matrix struct/class and make all members public

In C

typedef struct {
    singleRow a1;
    singleRow a2;
    singleRow a3;
} Matrix;
Enter fullscreen mode Exit fullscreen mode

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);
  }
}
Enter fullscreen mode Exit fullscreen mode

Wait for next part

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay