2 * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
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.
12 /* Header for utility functionality.
27 ///////////////////////////////////////////////////////////////////////////////
28 //! Write a tridiagonal, symmetric matrix in vector representation and
30 //! @param filename name of output file
31 //! @param d diagonal entries of the matrix
32 //! @param s superdiagonal entries of the matrix (len = n - 1)
33 //! @param eigenvals eigenvalues of the matrix
34 //! @param indices vector of len n containing the position of the eigenvalues
35 //! if these are sorted in ascending order
36 //! @param n size of the matrix
37 ///////////////////////////////////////////////////////////////////////////////
40 writeTridiagSymMatlab(const char *filename,
43 const unsigned int n);
45 ///////////////////////////////////////////////////////////////////////////////
46 //! Write matrix to a file in Matlab format
47 //! @param file file handle to which to write he matrix
48 //! @param mat_name name of matrix in Matlab
49 //! @param mat matrix to write to the file
50 //! @param mat_size size of the (square) matrix \a mat
51 ///////////////////////////////////////////////////////////////////////////////
52 template<class T, class S>
54 writeMatrixMatlab(T &file, const char *mat_name,
55 S *&mat, const unsigned int mat_size);
57 ///////////////////////////////////////////////////////////////////////////////
58 //! Write vector to a file in Matlab format
59 //! @param file file handle to which to write he matrix
60 //! @param vec_name name of vector in Matlab
61 //! @param vec matrix to write to the file
62 //! @param vec_len length of the vector
63 ///////////////////////////////////////////////////////////////////////////////
64 template<class T, class S>
66 writeVectorMatlab(T &file, const char *vec_name,
67 S *&vec, const unsigned int vec_len);
71 ///////////////////////////////////////////////////////////////////////////////
72 //! Write matrix to a file in Matlab format
73 //! @param file file handle to which to write he matrix
74 //! @param mat_name name of matrix in Matlab
75 //! @param mat matrix to write to the file
76 //! @param mat_size size of the (square) matrix \a mat
77 ///////////////////////////////////////////////////////////////////////////////
78 template<class T, class S>
80 writeMatrixMatlab(T &file, const char *mat_name,
81 S *&mat, const unsigned int mat_size)
84 const unsigned int pitch = sizeof(S) * mat_size;
86 file << mat_name << " = [";
88 for (unsigned int i = 0; i < mat_size; ++i)
90 for (unsigned int j = 0; j < mat_size; ++j)
93 file << getMatrix(mat, pitch, i, j) << " ";
96 if (i != mat_size - 1)
105 ///////////////////////////////////////////////////////////////////////////////
106 //! Write vector to a file in Matlab format
107 //! @param file file handle to which to write he matrix
108 //! @param vec_name name of vector in Matlab
109 //! @param vec matrix to write to the file
110 //! @param vec_len length of the vector
111 ///////////////////////////////////////////////////////////////////////////////
112 template<class T, class S>
114 writeVectorMatlab(T &file, const char *vec_name,
115 S *&vec, const unsigned int vec_len)
117 file << vec_name << " = [";
119 for (unsigned int i = 0; i < vec_len; ++i)
121 file << vec[i] << " ";