OSDN Git Service

new file: Integration/Tomography/Makefile.recent
[eos/hostdependX86LINUX64.git] / hostdepend / X86MAC64 / util / X86MAC64 / cuda / samples / 6_Advanced / eigenvalues / matlab.cpp
1 /*
2  * Copyright 1993-2013 NVIDIA Corporation.  All rights reserved.
3  *
4  * Please refer to the NVIDIA end user license agreement (EULA) associated
5  * with this source code for terms and conditions that govern your use of
6  * this software. Any use, reproduction, disclosure, or distribution of
7  * this software and related documentation outside the terms of the EULA
8  * is strictly prohibited.
9  *
10  */
11
12 //! includes, system
13 #include <cmath>
14 #include <iostream>
15 #include <iomanip>
16 #include <vector>
17 #include <cassert>
18 #include <fstream>
19 #include <algorithm>
20 #include <map>
21
22
23 // includes, projcet
24 #include "matlab.h"
25
26 // namespace, unnamed
27 namespace
28 {
29
30 } // end namespace, unnamed
31
32 ///////////////////////////////////////////////////////////////////////////////
33 //! Write a tridiagonal, symmetric matrix in vector representation and
34 //! it's eigenvalues
35 //! @param  filename  name of output file
36 //! @param  d  diagonal entries of the matrix
37 //! @param  s  superdiagonal entries of the matrix (len = n - 1)
38 //! @param  eigenvals  eigenvalues of the matrix
39 //! @param  indices  vector of len n containing the position of the eigenvalues
40 //!                  if these are sorted in ascending order
41 //! @param  n  size of the matrix
42 ///////////////////////////////////////////////////////////////////////////////
43 void
44 writeTridiagSymMatlab(const char *filename,
45                       float *d, float *s,
46                       float *eigenvals,
47                       const unsigned int n)
48 {
49     std::ofstream file(filename, std::ios::out);
50
51     // write diagonal entries
52     writeVectorMatlab(file, "d", d, n);
53
54     // write superdiagonal entries
55     writeVectorMatlab(file, "s", s, n-1);
56
57     // write eigenvalues
58     writeVectorMatlab(file, "eigvals", eigenvals, n);
59
60     file.close();
61 }