Question
USING C++ Create a 4x4 matrix initialized to identity, all entries 0 except diagonal entries. Mat4 m; Create a 4x4 matrix initialized using the passed
USING C++
Create a 4x4 matrix initialized to identity, all entries 0 except diagonal entries.
Mat4 m;
Create a 4x4 matrix initialized using the passed array. Row major.
double arr[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; Mat4 m(arr);
The above creates the following matrix
1234 5678 9 10 11 12 13 14 15 16
Create a matrix using an exising matrix
Mat4 m1; Mat4 m2(m1);
Assign one matrix to anther matrix
Mat4 m1; Mat4 m2;
m2 = m1;
Ability to read/write an element of the matrix
Mat m; double& v = m.at(1,1); cout << v << endl; v = 10;
Ability to print the contents of a matrix
Mat m; m.print()
The above prints
1000 0100 0010 0001
And after using the element-wise read/write
double& v = m.at(1,1); v = 10; m.show();
We get
1000 0 10 0 0 0010 0001
Ability to multiple two matrices
Mat m1; Mat m2;
m1.dot(m2);
m1 is now equal to m1*m2.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started