Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78919484
ch-06-ex-02-solution.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 23, 18:22
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Aug 25, 18:22 (2 d)
Engine
blob
Format
Raw Data
Handle
20122051
Attached To
R9360 PCSC_git
ch-06-ex-02-solution.cpp
View Options
/*
* chapter-06-exercise-02.cpp
*
* Test for class of 2x2 double precision matrix
*
* Created on: Oct 21, 2012
* Author: Radu Popescu <radu.popescu@epfl.ch>
*/
#include <iostream>
#include "DoubleMatrix2x2.hpp"
int main(int argc, char *argv[]) {
// Build a matrix with the empty constructor
DoubleMatrix2x2 A;
std::cout << "Matrix A is:\n" << A << std::endl;
// Build a matrix with the non-empty constructor
DoubleMatrix2x2 B(1.0, 2.0, 3.0, 4.0);
std::cout << "Matrix B is:\n" << B << std::endl;
// Build a matrix with the copy constructor
DoubleMatrix2x2 C(B);
std::cout << "Matrix C is:\n" << C << std::endl;
// Test the determinant method
std::cout << "The determinant of C is: " << C.Determinant() << std::endl;
// Test inverse
DoubleMatrix2x2 InvC = C.Inverse();
std::cout << "The inverse of C is:\n" << InvC << std::endl;
// Test the assignment operator
DoubleMatrix2x2 D;
D = C;
std::cout << "Matrix D is:\n" << D << std::endl;
// Testing some operators
DoubleMatrix2x2 E(-D);
E = E + D;
E = E - D;
E.Multiply(2.0);
std::cout << "Matrix E is:\n" << E << std::endl;
return 0;
}
Event Timeline
Log In to Comment