Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions