Bugzilla – Attachment 537 Details for
Bug 949
Add static assertion for incompatible scalar types in decompositions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
Demo
eigen_demo.cpp (text/x-csrc), 2.50 KB, created by
sebastien.varrette
on 2015-02-08 22:04:27 UTC
(
hide
)
Description:
Demo
Filename:
MIME Type:
Creator:
sebastien.varrette
Created:
2015-02-08 22:04:27 UTC
Size:
2.50 KB
patch
obsolete
>#include <iostream> >#include <string> >#include <map> > >#include <Eigen/Core> >#include <Eigen/LU> > >int main(int argc, char *argv[]) >{ > Eigen::Matrix<int,3,3> A; > A << > -2, 2, -3, > -1, 1, 3, > 2, 0, -1; > Eigen::Matrix<int,4,4> B; > B << > 3, 2, 0, 1, > 4, 0, 1, 2, > 3, 0, 2, 1, > 9, 2, 3, 1; > Eigen::Matrix<int,5,5> C0, C1, C2; > > std::map< std::string, int> expected; // All examples checked > expected["A"] = 18; // http://en.wikipedia.org/wiki/Determinant > expected["B"] = 24; // https://people.richland.edu/james/lecture/m116/matrices/determinant.html > expected["C0"] = 99; // https://www.physicsforums.com/threads/find-the-determinant-of-a-5-x-5-matrix.146419/ > expected["C1"] = -25; // > expected["C2"] = 0; // see https://www.youtube.com/watch?v=_JetUVpvFAU > C0 << > 1, 2, 3, 4, 5, > 3, 0, 4, 5, 6, > 2, 1, 2, 3, 4, > 0, 0, 0, 6, 5, > 0, 0, 0, 5, 6; > C1 << > 0, 0, 3, 1, 1, > 3, 1, 1, 0, 1, > 1, 0, 2, 3, 3, > 3, 1, 2, 3, 3, > 0, 2, 1, 2, 1; > C2 << > 1, 1, 1, 1, 1, > 1, 2, 3, 4, 5, > 1, 3, 6, 10, 15, > 1, 4, 10, 20, 35, > 1, 5, 15, 35, 69; > > std::cout << "A = \n" << A << std::endl; > std::cout << "[OK] det(A) = " << A.determinant() << " -- expected: " << expected["A"] << std::endl; > std::cout << "B = \n" << B << std::endl; > std::cout << "[OK] det(B) = " << B.determinant() << " -- expected: " << expected["B"] << std::endl; > std::cout << "C0 = \n" << C0 << std::endl; > std::cout << "[WRONG] det(C0) = " << C0.determinant() << " -- expected: " << expected["C0"] << std::endl; > std::cout << "C1 = \n" << C1 << std::endl; > std::cout << "[WRONG] det(C1) = " << C1.determinant() << " -- expected: " << expected["C1"] << std::endl; > std::cout << "C2 = \n" << C2 << std::endl; > std::cout << "[WRONG] det(C2) = " << C2.determinant() << " -- expected: " << expected["C2"] << std::endl; > > return 0; >} >/* > Output of the execution of the above program: > > A = > -2 2 -3 > -1 1 3 > 2 0 -1 > [OK] det(A) = 18 -- expected: 18 > B = > 3 2 0 1 > 4 0 1 2 > 3 0 2 1 > 9 2 3 1 > [OK] det(B) = 24 -- expected: 24 > C0 = > 1 2 3 4 5 > 3 0 4 5 6 > 2 1 2 3 4 > 0 0 0 6 5 > 0 0 0 5 6 > [WRONG] det(C0) = -432 -- expected: 99 > C1 = > 0 0 3 1 1 > 3 1 1 0 1 > 1 0 2 3 3 > 3 1 2 3 3 > 0 2 1 2 1 > [WRONG] det(C1) = -54 -- expected: -25 > C2 = > 1 1 1 1 1 > 1 2 3 4 5 > 1 3 6 10 15 > 1 4 10 20 35 > 1 5 15 35 69 > [WRONG] det(C2) = 1296 -- expected: 0 > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 949
:
537
|
555
|
556