| 1 |
/************************************************************************* |
| 2 |
* * |
| 3 |
* Vega FEM Simulation Library Version 3.1 * |
| 4 |
* * |
| 5 |
* "matrix" library , Copyright (C) 2007 CMU, 2009 MIT * |
| 6 |
* All rights reserved. * |
| 7 |
* * |
| 8 |
* Code author: Jernej Barbic * |
| 9 |
* http://www.jernejbarbic.com/code * |
| 10 |
* Research: Jernej Barbic, Doug L. James, Jovan Popovic * |
| 11 |
* Funding: NSF, Link Foundation, Singapore-MIT GAMBIT Game Lab * |
| 12 |
* * |
| 13 |
* This library is free software; you can redistribute it and/or * |
| 14 |
* modify it under the terms of the BSD-style license that is * |
| 15 |
* included with this library in the file LICENSE.txt * |
| 16 |
* * |
| 17 |
* This library is distributed in the hope that it will be useful, * |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file * |
| 20 |
* LICENSE.TXT for more details. * |
| 21 |
* * |
| 22 |
*************************************************************************/ |
| 23 |
|
| 24 |
#include "matrix.h" |
| 25 |
|
| 26 |
/* |
| 27 |
A simple example using the matrix class. |
| 28 |
*/ |
| 29 |
|
| 30 |
int main() |
| 31 |
{ |
| 32 |
double Av[9] = {2.0, 1.0, 1.0, |
| 33 |
1.0, 2.0, 1.0, |
| 34 |
1.0, 1.0, 2.0, }; |
| 35 |
|
| 36 |
Matrix<double> A(3, 3, Av); |
| 37 |
Matrix<double> B = 0.5 * Transpose(A) * A; |
| 38 |
printf("Matrix:\n"); |
| 39 |
B.Print(); |
| 40 |
char outputFilename[96] = "BMatrix"; |
| 41 |
B.Save(outputFilename); |
| 42 |
|
| 43 |
Matrix<double> Q(3,3); // will hold eigenvectors |
| 44 |
Matrix<double> Lambda(3,1); // will hold eigenvalues |
| 45 |
B.SymmetricEigenDecomposition(Q, Lambda); |
| 46 |
|
| 47 |
printf("Eigenvalues:\n"); |
| 48 |
Lambda.Print(); |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |
| 52 |
|