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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!