Changeset 1121
- Timestamp:
- Feb 22, 2008, 4:29:56 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 69 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/alignment_test.cc
r1098 r1121 25 25 #include "yat/utility/Alignment.h" 26 26 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 29 29 #include <gsl/gsl_cdf.h> … … 76 76 const std::vector<double>& l2, 77 77 const double sigma, 78 theplu::yat::utility:: matrix& dot_matrix,78 theplu::yat::utility::Matrix& dot_matrix, 79 79 std::vector<std::pair<size_t,size_t> >& path) 80 80 { … … 109 109 for (size_t i=0; i<peaksets.size()-1; i++) 110 110 for (size_t j=i+1; j<peaksets.size(); j++) { 111 utility:: matrix dot_m;111 utility::Matrix dot_m; 112 112 std::vector<std::pair<size_t,size_t> > path; 113 113 score(peaksets[i], peaksets[j], 1.0, dot_m, path); … … 116 116 std::string a("AGGUUGUCCGUGGUGAGUUCGCA"); 117 117 std::string b("GAGGUUGUCCGUGGUGAGUUCG"); 118 utility:: matrix m(a.size(), b.size());118 utility::Matrix m(a.size(), b.size()); 119 119 for (size_t j=0; j<a.size(); ++j) 120 120 for (size_t k=0; k<b.size(); ++k) -
trunk/test/consensus_inputranker_test.cc
r1000 r1121 26 26 #include "yat/classifier/ConsensusInputRanker.h" 27 27 #include "yat/statistics/AUC.h" 28 #include "yat/utility/ matrix.h"28 #include "yat/utility/Matrix.h" 29 29 #include "yat/classifier/MatrixLookup.h" 30 30 #include "yat/classifier/CrossValidationSampler.h" … … 53 53 54 54 ifstream is("data/rank_data.txt"); 55 theplu::yat::utility:: matrix data_tmp(is);55 theplu::yat::utility::Matrix data_tmp(is); 56 56 theplu::yat::classifier::MatrixLookup data(data_tmp); 57 57 is.close(); … … 86 86 *error << "ok." << std::endl; 87 87 88 theplu::yat::utility:: matrix flag(data.rows(),data.columns(),1);88 theplu::yat::utility::Matrix flag(data.rows(),data.columns(),1); 89 89 // Peter, fix weighted version instead 90 90 theplu::yat::classifier::ConsensusInputRanker cir2(retrieve,median); -
trunk/test/data_lookup_1d_test.cc
r1120 r1121 23 23 */ 24 24 25 #include "yat/utility/ matrix.h"25 #include "yat/utility/Matrix.h" 26 26 #include "yat/classifier/DataLookup1D.h" 27 27 #include "yat/classifier/MatrixLookup.h" … … 37 37 using namespace theplu::yat; 38 38 39 utility:: matrix matrix(size_t n);39 utility::Matrix matrix(size_t n); 40 40 int end_test(std::ostream*, bool); 41 41 … … 57 57 58 58 *error << "Testing DataLookup1D" << std::endl; 59 utility:: matrix gsl_m1(matrix(5));59 utility::Matrix gsl_m1(matrix(5)); 60 60 std::vector<size_t> index_odd; 61 61 index_odd.push_back(1); … … 177 177 } 178 178 179 utility:: matrix matrix(size_t n)179 utility::Matrix matrix(size_t n) 180 180 { 181 utility:: matrix res(n,n);181 utility::Matrix res(n,n); 182 182 for (size_t i=0;i<n;i++) 183 183 for (size_t j=0;j<n;j++) -
trunk/test/distance_test.cc
r1120 r1121 26 26 #include "yat/statistics/EuclideanDistance.h" 27 27 #include "yat/statistics/PearsonDistance.h" 28 #include "yat/utility/ matrix.h"28 #include "yat/utility/Matrix.h" 29 29 #include "yat/utility/Vector.h" 30 30 … … 74 74 75 75 // Testing weighted versions 76 utility:: matrix m(2,3,1);76 utility::Matrix m(2,3,1); 77 77 m(0,1)=2; 78 78 m(1,0)=0; 79 79 m(1,1)=0; 80 utility:: matrix w(2,3,1);80 utility::Matrix w(2,3,1); 81 81 w(0,0)=0; 82 82 classifier::MatrixLookupWeighted mw(m,w); -
trunk/test/ensemble_test.cc
r1100 r1121 23 23 */ 24 24 25 #include "yat/utility/ matrix.h"25 #include "yat/utility/Matrix.h" 26 26 #include "yat/classifier/SubsetGenerator.h" 27 27 #include "yat/classifier/CrossValidationSampler.h" … … 62 62 *error << "loading data" << std::endl; 63 63 std::ifstream is("data/nm_data_centralized.txt"); 64 utility:: matrix data_core(is);64 utility::Matrix data_core(is); 65 65 is.close(); 66 66 -
trunk/test/feature_selection_test.cc
r1000 r1121 30 30 #include "yat/statistics/SNRScore.h" 31 31 32 #include "yat/utility/ matrix.h"32 #include "yat/utility/Matrix.h" 33 33 34 34 #include <algorithm> … … 60 60 *error << "Reading in Sorlie data to identify top gene ..." << std::endl; 61 61 std::ifstream is("data/sorlie_centroid_data.txt"); 62 utility:: matrix data(is,'\t');62 utility::Matrix data(is,'\t'); 63 63 is.close(); 64 64 … … 70 70 71 71 // Generate weight matrix with 0 for missing values and 1 for others. 72 utility:: matrix weights(data.rows(),data.columns(),0.0);72 utility::Matrix weights(data.rows(),data.columns(),0.0); 73 73 for(size_t i=0;i<data.rows();++i) 74 74 for(size_t j=0;j<data.columns();++j) -
trunk/test/inputranker_test.cc
r1000 r1121 26 26 #include "yat/classifier/InputRanker.h" 27 27 #include "yat/statistics/AUC.h" 28 #include "yat/utility/ matrix.h"28 #include "yat/utility/Matrix.h" 29 29 #include "yat/classifier/MatrixLookup.h" 30 30 #include "yat/classifier/Target.h" … … 51 51 52 52 std::ifstream is("data/rank_data.txt"); 53 theplu::yat::utility:: matrix data_tmp(is);53 theplu::yat::utility::Matrix data_tmp(is); 54 54 theplu::yat::classifier::MatrixLookup data(data_tmp); 55 55 is.close(); -
trunk/test/iterator_test.cc
r1120 r1121 27 27 #include "yat/classifier/MatrixLookupWeighted.h" 28 28 #include "yat/utility/Container2DIterator.h" 29 #include "yat/utility/ matrix.h"29 #include "yat/utility/Matrix.h" 30 30 #include "yat/utility/Vector.h" 31 31 … … 73 73 74 74 // test std algorithm on IteratorWeighted 75 utility:: matrix m(1,3,1);75 utility::Matrix m(1,3,1); 76 76 m(0,1)=2.0; 77 utility:: matrix w(1,3,1);77 utility::Matrix w(1,3,1); 78 78 classifier::MatrixLookupWeighted mw(m,w); 79 79 classifier::DataLookupWeighted1D aw(mw,0,true); -
trunk/test/kernel_lookup_test.cc
r1000 r1121 22 22 */ 23 23 24 #include "yat/utility/ matrix.h"24 #include "yat/utility/Matrix.h" 25 25 #include "yat/classifier/DataLookup1D.h" 26 26 #include "yat/classifier/KernelLookup.h" … … 50 50 bool ok =true; 51 51 *error << "\nTesting KernelLookup" << std::endl; 52 utility:: matrix data_core(1,5);52 utility::Matrix data_core(1,5); 53 53 for (size_t i=0; i<data_core.columns(); i++) 54 54 data_core(0,i)=i; -
trunk/test/kernel_test.cc
r1098 r1121 24 24 */ 25 25 26 #include "yat/utility/ matrix.h"26 #include "yat/utility/Matrix.h" 27 27 #include "yat/classifier/KernelFunction.h" 28 28 #include "yat/classifier/PolynomialKernelFunction.h" … … 43 43 bool test_MEV(const classifier::MatrixLookup& data, 44 44 const classifier::KernelFunction* kf, 45 const utility:: matrix& control, const double error_bound,45 const utility::Matrix& control, const double error_bound, 46 46 std::ostream* error); 47 47 48 48 bool test_SEV(const classifier::MatrixLookup& data, 49 49 const classifier::KernelFunction* kf, 50 const utility:: matrix& control, const double error_bound,50 const utility::Matrix& control, const double error_bound, 51 51 std::ostream* error); 52 52 … … 66 66 bool ok = true; 67 67 68 utility:: matrix data2_core(2,3);68 utility::Matrix data2_core(2,3); 69 69 data2_core(0,0)=0; 70 70 data2_core(1,0)=0; … … 95 95 double error_bound = 1e-8; 96 96 std::ifstream is("data/nm_data_centralized.txt"); 97 utility:: matrix data_core(is);97 utility::Matrix data_core(is); 98 98 is.close(); 99 99 … … 101 101 102 102 is.open("data/nm_kernel.txt"); 103 utility:: matrix kernel_matlab(is);103 utility::Matrix kernel_matlab(is); 104 104 is.close(); 105 105 classifier::KernelFunction* kf = new classifier::PolynomialKernelFunction(); … … 109 109 110 110 is.open("data/nm_kernel2.txt"); 111 utility:: matrix kernel_matlab2(is);111 utility::Matrix kernel_matlab2(is); 112 112 is.close(); 113 113 kf = new classifier::PolynomialKernelFunction(2); … … 119 119 *error << "Checking GaussianKernelFunction.\n"; 120 120 is.open("data/nm_kernel_gaussian.txt"); 121 utility:: matrix kernel_gaussian(is);121 utility::Matrix kernel_gaussian(is); 122 122 is.close(); 123 123 kf = new classifier::GaussianKernelFunction(100); … … 144 144 bool test_MEV(const classifier::MatrixLookup& data, 145 145 const classifier::KernelFunction* kf, 146 const utility:: matrix& control, const double error_bound,146 const utility::Matrix& control, const double error_bound, 147 147 std::ostream* error) 148 148 { … … 182 182 bool test_SEV(const classifier::MatrixLookup& data, 183 183 const classifier::KernelFunction* kf, 184 const utility:: matrix& control, const double error_bound,184 const utility::Matrix& control, const double error_bound, 185 185 std::ostream* error) 186 186 { -
trunk/test/knn_test.cc
r1112 r1121 28 28 #include "yat/classifier/MatrixLookupWeighted.h" 29 29 #include "yat/statistics/EuclideanDistance.h" 30 #include "yat/utility/ matrix.h"30 #include "yat/utility/Matrix.h" 31 31 32 32 … … 41 41 using namespace theplu::yat; 42 42 43 double deviation(const utility:: matrix& a, const utility::matrix& b) {43 double deviation(const utility::Matrix& a, const utility::Matrix& b) { 44 44 double sl=0; 45 45 for (size_t i=0; i<a.rows(); i++){ … … 70 70 //////////////////////////////////////////////////////////////// 71 71 *error << "test of predictions using unweighted training and test data\n"; 72 utility:: matrix data1(3,4);72 utility::Matrix data1(3,4); 73 73 for(size_t i=0;i<3;i++) { 74 74 data1(i,0)=3-i; … … 87 87 knn1.k(3); 88 88 knn1.train(); 89 utility:: matrix prediction1;89 utility::Matrix prediction1; 90 90 knn1.predict(ml1,prediction1); 91 91 double slack_bound=2e-7; 92 utility:: matrix result1(2,4);92 utility::Matrix result1(2,4); 93 93 result1(0,0)=result1(0,1)=result1(1,2)=result1(1,3)=2.0; 94 94 result1(0,2)=result1(0,3)=result1(1,0)=result1(1,1)=1.0; … … 106 106 //////////////////////////////////////////////////////////////// 107 107 *error << "test of predictions using unweighted training and weighted test data\n"; 108 utility:: matrix weights1(3,4,1.0);108 utility::Matrix weights1(3,4,1.0); 109 109 weights1(2,0)=0; 110 110 classifier::MatrixLookupWeighted mlw1(data1,weights1); … … 125 125 *error << "test of predictions using weighted training and test data\n"; 126 126 weights1(0,1)=0; 127 utility:: matrix weights2(3,4,1.0);127 utility::Matrix weights2(3,4,1.0); 128 128 weights2(2,3)=0; 129 129 classifier::MatrixLookupWeighted mlw2(data1,weights2); … … 146 146 // A test of reciprocal ranks weighting with training and test both weighted 147 147 //////////////////////////////////////////////////////////////// 148 utility:: matrix data2(data1);148 utility::Matrix data2(data1); 149 149 data2(1,3)=7; 150 150 classifier::MatrixLookupWeighted mlw3(data2,weights2); -
trunk/test/matrix_lookup_test.cc
r1000 r1121 22 22 */ 23 23 24 #include "yat/utility/ matrix.h"24 #include "yat/utility/Matrix.h" 25 25 #include "yat/classifier/MatrixLookup.h" 26 26 … … 31 31 using namespace theplu::yat; 32 32 33 utility:: matrix matrix(size_t n);33 utility::Matrix matrix(size_t n); 34 34 35 35 int main(const int argc,const char* argv[]) … … 48 48 49 49 *error << "\nTesting MatrixLookup" << std::endl; 50 *error << "MatrixLookup::MatrixLookup(const utility:: matrix& data)...";51 utility:: matrix gsl_m1(matrix(2));50 *error << "MatrixLookup::MatrixLookup(const utility::Matrix& data)..."; 51 utility::Matrix gsl_m1(matrix(2)); 52 52 classifier::MatrixLookup m1(gsl_m1); 53 53 if (m1.rows()!=gsl_m1.rows() || m1.columns()!=gsl_m1.columns() || … … 61 61 62 62 63 *error << "MatrixLookup::MatrixLookup(const utility:: matrix&,\n"63 *error << "MatrixLookup::MatrixLookup(const utility::Matrix&,\n" 64 64 << " const std::vector<size_t>&,\n" 65 65 << " const std::vector<size_t>&)..."; 66 utility:: matrix gsl_m2(matrix(4));66 utility::Matrix gsl_m2(matrix(4)); 67 67 std::vector<size_t> index_odd; 68 68 index_odd.push_back(1); … … 82 82 *error << "Ok" << std::endl; 83 83 84 *error << "MatrixLookup::MatrixLookup(const utility:: matrix&,\n"84 *error << "MatrixLookup::MatrixLookup(const utility::Matrix&,\n" 85 85 << " const std::vector<size_t>&,\n" 86 86 << " const bool)..."; … … 173 173 } 174 174 175 utility:: matrix matrix(size_t n)175 utility::Matrix matrix(size_t n) 176 176 { 177 utility:: matrix res(n,n);177 utility::Matrix res(n,n); 178 178 for (size_t i=0;i<n;i++) 179 179 for (size_t j=0;j<n;j++) -
trunk/test/matrix_test.cc
r1120 r1121 24 24 */ 25 25 26 #include "yat/utility/ matrix.h"26 #include "yat/utility/Matrix.h" 27 27 28 28 #include <cstdio> … … 39 39 row(const size_t& i) { return m_.row_view(i); } 40 40 41 inline const theplu::yat::utility:: matrix& matrix(void) const { return m_; }41 inline const theplu::yat::utility::Matrix& matrix(void) const { return m_; } 42 42 43 43 private: 44 theplu::yat::utility:: matrix m_;44 theplu::yat::utility::Matrix m_; 45 45 }; 46 46 … … 60 60 *error << "Testing matrix class" << std::endl; 61 61 bool ok = true; 62 utility:: matrix unit3x3(3,3);62 utility::Matrix unit3x3(3,3); 63 63 for (size_t i=0; i<unit3x3.rows(); ++i) 64 64 unit3x3(i,i)=1; 65 65 66 66 *error << "\tcopy constructor and operator!=" << std::endl; 67 utility:: matrix m(3,3,9);68 utility:: matrix m2(m);67 utility::Matrix m(3,3,9); 68 utility::Matrix m2(m); 69 69 if (m2!=m) 70 70 ok=false; … … 77 77 my_out.close(); 78 78 std::ifstream is("data/tmp_test_matrix.txt"); 79 utility:: matrix m3(is);79 utility::Matrix m3(is); 80 80 is.close(); 81 81 if (m3!=m2) … … 84 84 85 85 *error << "\toperator*=(double)" << std::endl; 86 utility:: matrix m4(3,3,1);86 utility::Matrix m4(3,3,1); 87 87 m4 *= 9; 88 88 if (m4!=m) { … … 95 95 // lines and other whitespaces. The file is not expected to break 96 96 // things. 97 utility:: matrix m5(is);97 utility::Matrix m5(is); 98 98 is.close(); 99 99 double m5_sum=0; … … 106 106 { 107 107 *error << "\tcopy constructor" << std::endl; 108 utility:: matrix m2(m5);108 utility::Matrix m2(m5); 109 109 ok &= (m2.rows()==m5.rows()); 110 110 ok &= (m2.columns()==m5.columns()); … … 202 202 *error << "\tmatrix::nan()" << std::endl; 203 203 is.open("data/sorlie_centroid_data.txt"); 204 utility:: matrix* m_nan = new utility::matrix(is,'\t');205 utility:: matrix m_weight;204 utility::Matrix* m_nan = new utility::Matrix(is,'\t'); 205 utility::Matrix m_weight; 206 206 utility::nan(*m_nan,m_weight); 207 207 is.close(); … … 219 219 220 220 *error << "\toperator*=(matrix&)" << std::endl; 221 utility:: matrix m6(unit3x3);221 utility::Matrix m6(unit3x3); 222 222 m6 *= m; 223 223 if (m6!=m) { … … 230 230 *error << "error operator*=(matrix) 2" << std::endl; 231 231 } 232 m6*= utility:: matrix(3,4,1.0);233 m6*= utility:: matrix(4,3,1.0);234 m6*= utility:: matrix(3,5,2.0);235 m6*= utility:: matrix(5,5,2.0);236 m6*= utility:: matrix(5,3,2.0);232 m6*= utility::Matrix(3,4,1.0); 233 m6*= utility::Matrix(4,3,1.0); 234 m6*= utility::Matrix(3,5,2.0); 235 m6*= utility::Matrix(5,5,2.0); 236 m6*= utility::Matrix(5,3,2.0); 237 237 m6*= unit3x3; 238 238 -
trunk/test/nbc_test.cc
r1000 r1121 26 26 #include "yat/classifier/NBC.h" 27 27 #include "yat/classifier/Target.h" 28 #include "yat/utility/ matrix.h"28 #include "yat/utility/Matrix.h" 29 29 30 30 #include <cassert> … … 50 50 51 51 std::ifstream is("data/nm_data_centralized.txt"); 52 utility:: matrix data_core(is);52 utility::Matrix data_core(is); 53 53 is.close(); 54 54 classifier::MatrixLookup data(data_core); … … 62 62 *error << "Training NBC" << std::endl; 63 63 nbc.train(); 64 utility:: matrix res;64 utility::Matrix res; 65 65 *error << "Predicting" << std::endl; 66 66 nbc.predict(data, res); -
trunk/test/ncc_test.cc
r1084 r1121 30 30 #include "yat/classifier/PolynomialKernelFunction.h" 31 31 #include "yat/classifier/Target.h" 32 #include "yat/utility/ matrix.h"32 #include "yat/utility/Matrix.h" 33 33 #include "yat/statistics/EuclideanDistance.h" 34 34 #include "yat/statistics/PearsonDistance.h" … … 46 46 using namespace theplu::yat; 47 47 48 double deviation(const utility:: matrix& a, const utility::matrix& b) {48 double deviation(const utility::Matrix& a, const utility::Matrix& b) { 49 49 double sl=0; 50 50 for (size_t i=0; i<a.rows(); i++){ … … 87 87 ///////////////////////////////////////////// 88 88 *error << "test of predictions using unweighted test data\n"; 89 utility:: matrix data1(3,4);89 utility::Matrix data1(3,4); 90 90 for(size_t i=0;i<3;i++) { 91 91 data1(i,0)=3-i; … … 103 103 classifier::NCC<statistics::EuclideanDistance> ncc1(ml1,target1); 104 104 ncc1.train(); 105 utility:: matrix prediction1;105 utility::Matrix prediction1; 106 106 ncc1.predict(ml1,prediction1); 107 107 double slack_bound=2e-7; 108 utility:: matrix result1(2,4);108 utility::Matrix result1(2,4); 109 109 result1(0,0)=result1(0,1)=result1(1,2)=result1(1,3)=sqrt(3.0); 110 110 result1(0,2)=result1(0,3)=result1(1,0)=result1(1,1)=sqrt(11.0); … … 121 121 ////////////////////////////////////////////////////////////////////////// 122 122 *error << "test of predictions using unweighted training and weighted test data\n"; 123 utility:: matrix weights1(3,4,1.0);123 utility::Matrix weights1(3,4,1.0); 124 124 weights1(0,0)=weights1(1,1)=weights1(2,2)=weights1(1,3)=0.0; 125 125 classifier::MatrixLookupWeighted mlw1(data1,weights1); … … 139 139 ////////////////////////////////////////////////////////////////////////// 140 140 *error << "test of predictions using nan centroids and unweighted test data\n"; 141 utility:: matrix weights2(3,4,1.0);141 utility::Matrix weights2(3,4,1.0); 142 142 weights2(1,0)=weights2(1,1)=0.0; 143 143 classifier::MatrixLookupWeighted mlw2(data1,weights2); … … 163 163 *error << "test with Sorlie data\n"; 164 164 std::ifstream is("data/sorlie_centroid_data.txt"); 165 utility:: matrix data(is,'\t');165 utility::Matrix data(is,'\t'); 166 166 is.close(); 167 167 … … 171 171 172 172 // Generate weight matrix with 0 for missing values and 1 for others. 173 utility:: matrix weights(data.rows(),data.columns(),0.0);173 utility::Matrix weights(data.rows(),data.columns(),0.0); 174 174 utility::nan(data,weights); 175 175 … … 181 181 // Comparing the centroids to stored result 182 182 is.open("data/sorlie_centroids.txt"); 183 utility:: matrix centroids(is);183 utility::Matrix centroids(is); 184 184 is.close(); 185 185 … … 202 202 203 203 *error << "...predicting...\n"; 204 utility:: matrix prediction;204 utility::Matrix prediction; 205 205 ncc.predict(dataviewweighted,prediction); 206 206 207 207 // Comparing the prediction to stored result 208 208 is.open("data/sorlie_centroid_predictions.txt"); 209 utility:: matrix result(is,'\t');209 utility::Matrix result(is,'\t'); 210 210 is.close(); 211 211 -
trunk/test/nni_test.cc
r1000 r1121 25 25 26 26 #include "yat/utility/FileUtil.h" 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 #include "yat/utility/kNNI.h" 29 29 #include "yat/utility/WeNNI.h" … … 65 65 std::ifstream data_stream(knni_data.c_str()); 66 66 std::ifstream weight_stream(knni_weight.c_str()); 67 utility:: matrix data(data_stream);68 utility:: matrix weight(weight_stream);67 utility::Matrix data(data_stream); 68 utility::Matrix weight(weight_stream); 69 69 utility::kNNI knni(data,weight,neighbours); 70 70 knni.estimate(); 71 71 std::ifstream control_stream(knni_result.c_str()); 72 utility:: matrix control(control_stream);72 utility::Matrix control(control_stream); 73 73 control-=knni.imputed_data(); 74 74 double error_bound = 5e-13; … … 96 96 // test WeNNI 97 97 data_stream.open(wenni_data.c_str()); 98 data=utility:: matrix(data_stream);98 data=utility::Matrix(data_stream); 99 99 weight_stream.open(wenni_weight.c_str()); 100 weight=utility:: matrix(weight_stream);100 weight=utility::Matrix(weight_stream); 101 101 utility::WeNNI wenni(data,weight,neighbours); 102 102 wenni.estimate(); 103 103 control_stream.open(wenni_result.c_str()); 104 control=utility:: matrix(control_stream);104 control=utility::Matrix(control_stream); 105 105 control-=wenni.imputed_data(); 106 106 for (unsigned int i=0; i<control.rows(); i++) … … 127 127 // test WeNNI with binary weights 128 128 data_stream.open(knni_data.c_str()); 129 data=utility:: matrix(data_stream);129 data=utility::Matrix(data_stream); 130 130 weight_stream.open(knni_weight.c_str()); 131 weight=utility:: matrix(weight_stream);131 weight=utility::Matrix(weight_stream); 132 132 utility::WeNNI wenni2(data,weight,neighbours); 133 133 wenni2.estimate(); 134 134 control_stream.open(knni_result.c_str()); 135 control=utility:: matrix(control_stream);135 control=utility::Matrix(control_stream); 136 136 control-=wenni2.imputed_data(); 137 137 for (unsigned int i=0; i<control.rows(); i++) -
trunk/test/pca_test.cc
r1098 r1121 25 25 */ 26 26 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 #include "yat/utility/PCA.h" 29 29 … … 37 37 { 38 38 using namespace theplu::yat; 39 utility:: matrix A( 3, 4 );39 utility::Matrix A( 3, 4 ); 40 40 for( size_t i = 0; i < 3; ++i ) 41 41 for( size_t j = 0; j < 4; ++j ) -
trunk/test/regression_test.cc
r1120 r1121 30 30 #include "yat/regression/Polynomial.h" 31 31 #include "yat/regression/PolynomialWeighted.h" 32 #include "yat/utility/ matrix.h"32 #include "yat/utility/Matrix.h" 33 33 #include "yat/utility/Vector.h" 34 34 … … 207 207 { 208 208 std::ifstream s("data/regression_gauss.data"); 209 utility:: matrix data(s);209 utility::Matrix data(s); 210 210 utility::Vector x(data.rows()); 211 211 utility::Vector ln_y(data.rows()); … … 416 416 utility::Vector w(5,1.0); 417 417 418 utility:: matrix data(5,3);418 utility::Matrix data(5,3); 419 419 for (size_t i=0; i<data.rows(); ++i){ 420 420 data(i,0)=1; -
trunk/test/roc_test.cc
r1120 r1121 26 26 #include "yat/statistics/ROC.h" 27 27 #include "yat/statistics/utility.h" 28 #include "yat/utility/matrix.h"29 28 #include "yat/utility/Vector.h" 30 29 -
trunk/test/score_test.cc
r1120 r1121 30 30 #include "yat/statistics/tScore.h" 31 31 #include "yat/statistics/WilcoxonFoldChange.h" 32 #include "yat/utility/ matrix.h"32 #include "yat/utility/Matrix.h" 33 33 #include "yat/utility/Vector.h" 34 34 #include "yat/utility/VectorView.h" … … 79 79 80 80 std::ifstream is("data/rank_data.txt"); 81 utility:: matrix data(is);81 utility::Matrix data(is); 82 82 is.close(); 83 83 -
trunk/test/smart_ptr_test.cc
r1045 r1121 23 23 24 24 #include "yat/utility/SmartPtr.h" 25 #include "yat/utility/ matrix.h"25 #include "yat/utility/Matrix.h" 26 26 27 27 #include <fstream> … … 45 45 bool ok = true; 46 46 47 utility::SmartPtr<utility:: matrix> m(new utility::matrix(10,10));47 utility::SmartPtr<utility::Matrix> m(new utility::Matrix(10,10)); 48 48 if (m->columns()==10){ 49 utility::SmartPtr<utility:: matrix> m2(m);49 utility::SmartPtr<utility::Matrix> m2(m); 50 50 m2 = m; 51 51 } … … 54 54 55 55 m = m; 56 utility:: matrix m2 = *m;56 utility::Matrix m2 = *m; 57 57 58 58 if (m->columns()!=10) -
trunk/test/subset_generator_test.cc
r1086 r1121 34 34 #include "yat/classifier/NCC.h" 35 35 #include "yat/statistics/AUC.h" 36 #include "yat/utility/ matrix.h"36 #include "yat/utility/Matrix.h" 37 37 38 38 #include <cassert> … … 85 85 is.open("data/nm_data_centralized.txt"); 86 86 *error << "loading data " << std::endl; 87 utility:: matrix m(is);87 utility::Matrix m(is); 88 88 is.close(); 89 89 classifier::MatrixLookup data(m); … … 123 123 124 124 classifier::Target target(label); 125 utility:: matrix raw_data2(2,9);125 utility::Matrix raw_data2(2,9); 126 126 for(size_t i=0;i<raw_data2.rows();i++) 127 127 for(size_t j=0;j<raw_data2.columns();j++) … … 304 304 305 305 classifier::Target target(label); 306 utility:: matrix raw_data(10,10);306 utility::Matrix raw_data(10,10); 307 307 classifier::MatrixLookup data(raw_data); 308 308 classifier::BootstrapSampler cv(target,3); … … 321 321 322 322 classifier::Target target(label); 323 utility:: matrix raw_data(10,10);323 utility::Matrix raw_data(10,10); 324 324 classifier::MatrixLookup data(raw_data); 325 325 classifier::CrossValidationSampler cv(target,3,3); -
trunk/test/svd_test.cc
r1120 r1121 26 26 27 27 #include "yat/random/random.h" 28 #include "yat/utility/ matrix.h"28 #include "yat/utility/Matrix.h" 29 29 #include "yat/utility/SVD.h" 30 30 #include "yat/utility/Vector.h" … … 32 32 using namespace theplu::yat; 33 33 34 double this_norm(const utility:: matrix& A)34 double this_norm(const utility::Matrix& A) 35 35 { 36 36 double sum=0.0; … … 49 49 // initialise a random test-matrix 50 50 theplu::yat::random::ContinuousUniform rnd; 51 utility:: matrix A(m,n);51 utility::Matrix A(m,n); 52 52 for (size_t i=0; i<m; ++i) 53 53 for(size_t j=0; j<n; ++j) … … 57 57 svd.decompose(algo); 58 58 theplu::yat::utility::Vector s(svd.s()); 59 utility:: matrix S(s.size(),s.size());59 utility::Matrix S(s.size(),s.size()); 60 60 for (size_t i=0; i<s.size(); ++i) 61 61 S(i,i)=s[i]; 62 utility:: matrix Vtranspose=svd.V();62 utility::Matrix Vtranspose=svd.V(); 63 63 Vtranspose.transpose(); 64 64 // Reconstructing A = U*S*Vtranspose 65 utility:: matrix Areconstruct(svd.U());65 utility::Matrix Areconstruct(svd.U()); 66 66 Areconstruct*=S; 67 67 Areconstruct*=Vtranspose; … … 86 86 } 87 87 88 utility:: matrix Utranspose(svd.U());88 utility::Matrix Utranspose(svd.U()); 89 89 Utranspose.transpose(); 90 90 Utranspose*=svd.U(); // Expect unity matrix -
trunk/test/svm_test.cc
r1120 r1121 31 31 #include "yat/classifier/PolynomialKernelFunction.h" 32 32 #include "yat/classifier/Target.h" 33 #include "yat/utility/ matrix.h"33 #include "yat/utility/Matrix.h" 34 34 #include "yat/utility/Vector.h" 35 35 … … 56 56 bool ok = true; 57 57 58 utility:: matrix data2_core(2,3);58 utility::Matrix data2_core(2,3); 59 59 data2_core(0,0)=0; 60 60 data2_core(1,0)=0; … … 112 112 113 113 std::ifstream is("data/nm_data_centralized.txt"); 114 utility:: matrix data_core(is);114 utility::Matrix data_core(is); 115 115 is.close(); 116 116 -
trunk/test/view_test.cc
r1119 r1121 22 22 */ 23 23 24 #include "yat/utility/ matrix.h"24 #include "yat/utility/Matrix.h" 25 25 #include "yat/utility/VectorBase.h" 26 26 #include "yat/utility/VectorMutable.h" … … 46 46 bool ok = true; 47 47 48 matrix data1;48 Matrix data1; 49 49 data1.resize(3,1); 50 50 for(size_t i=0;i<3;i++) { … … 52 52 } 53 53 54 matrix data2(3,1,1.0);54 Matrix data2(3,1,1.0); 55 55 56 56 VectorConstView a=data1.column_const_view(0); -
trunk/yat/classifier/DataLookup1D.cc
r1120 r1121 28 28 #include "MatrixLookup.h" 29 29 30 #include "yat/utility/ matrix.h"30 #include "yat/utility/Matrix.h" 31 31 #include "yat/utility/Vector.h" 32 32 … … 66 66 : column_vector_(true), index_(0), owner_(true) 67 67 { 68 utility:: matrix* m = new utility::matrix(1,index.size());68 utility::Matrix* m = new utility::Matrix(1,index.size()); 69 69 for (size_t i=0; i<index.size(); ++i){ 70 70 assert(index[i]<v.size()); … … 78 78 : column_vector_(false), index_(0), owner_(true) 79 79 { 80 utility:: matrix* m = new utility::matrix(1,v.size());80 utility::Matrix* m = new utility::Matrix(1,v.size()); 81 81 for (size_t i=0; i<v.size(); ++i){ 82 82 (*m)(0,i)=v(i); -
trunk/yat/classifier/EnsembleBuilder.h
r1088 r1121 31 31 #include "SubsetGenerator.h" 32 32 #include "yat/statistics/Averager.h" 33 #include "yat/utility/Matrix.h" 33 34 34 35 #include <vector> … … 177 178 result.push_back(std::vector<statistics::Averager>(data.columns())); 178 179 179 utility:: matrix prediction;180 utility::Matrix prediction; 180 181 181 182 for(u_long k=0;k<subset_->size();++k) { … … 203 204 validation_result_.push_back(std::vector<statistics::Averager>(subset_->target().size())); 204 205 205 utility:: matrix prediction;206 utility::Matrix prediction; 206 207 for(u_long k=0;k<subset_->size();k++) { 207 208 classifier(k).predict(subset_->validation_data(k),prediction); -
trunk/yat/classifier/KNN.h
r1115 r1121 32 32 #include "SupervisedClassifier.h" 33 33 #include "Target.h" 34 #include "yat/utility/ matrix.h"34 #include "yat/utility/Matrix.h" 35 35 #include "yat/utility/yat_assert.h" 36 36 … … 107 107 /// 108 108 /// 109 void predict(const DataLookup2D&, utility:: matrix&) const;109 void predict(const DataLookup2D&, utility::Matrix&) const; 110 110 111 111 … … 129 129 /// generated and needs to be deleted by the caller. 130 130 /// 131 utility:: matrix* calculate_distances(const DataLookup2D&) const;131 utility::Matrix* calculate_distances(const DataLookup2D&) const; 132 132 133 133 void calculate_unweighted(const MatrixLookup&, 134 134 const MatrixLookup&, 135 utility:: matrix*) const;135 utility::Matrix*) const; 136 136 void calculate_weighted(const MatrixLookupWeighted&, 137 137 const MatrixLookupWeighted&, 138 utility:: matrix*) const;138 utility::Matrix*) const; 139 139 }; 140 140 … … 162 162 163 163 template <typename Distance, typename NeighborWeighting> 164 utility:: matrix* KNN<Distance, NeighborWeighting>::calculate_distances164 utility::Matrix* KNN<Distance, NeighborWeighting>::calculate_distances 165 165 (const DataLookup2D& test) const 166 166 { 167 167 // matrix with training samples as rows and test samples as columns 168 utility:: matrix* distances =169 new utility:: matrix(data_.columns(),test.columns());168 utility::Matrix* distances = 169 new utility::Matrix(data_.columns(),test.columns()); 170 170 171 171 … … 210 210 void KNN<Distance, NeighborWeighting>::calculate_unweighted 211 211 (const MatrixLookup& training, const MatrixLookup& test, 212 utility:: matrix* distances) const212 utility::Matrix* distances) const 213 213 { 214 214 for(size_t i=0; i<training.columns(); i++) { … … 226 226 KNN<Distance, NeighborWeighting>::calculate_weighted 227 227 (const MatrixLookupWeighted& training, const MatrixLookupWeighted& test, 228 utility:: matrix* distances) const228 utility::Matrix* distances) const 229 229 { 230 230 for(size_t i=0; i<training.columns(); i++) { … … 295 295 template <typename Distance, typename NeighborWeighting> 296 296 void KNN<Distance, NeighborWeighting>::predict(const DataLookup2D& test, 297 utility:: matrix& prediction) const297 utility::Matrix& prediction) const 298 298 { 299 299 utility::yat_assert<std::runtime_error>(data_.rows()==test.rows()); 300 300 301 utility:: matrix* distances=calculate_distances(test);301 utility::Matrix* distances=calculate_distances(test); 302 302 303 303 prediction.resize(target_.nof_classes(),test.columns(),0.0); -
trunk/yat/classifier/KernelLookup.cc
r1105 r1121 26 26 #include "MatrixLookup.h" 27 27 #include "MatrixLookupWeighted.h" 28 #include " ../utility/matrix.h"28 #include "yat/utility/Matrix.h" 29 29 30 30 #include <cassert> … … 205 205 assert(data.rows()==kernel_->data().rows()); 206 206 if (!weighted()){ 207 utility:: matrix* data_all =208 new utility:: matrix(data.rows(), row_index_.size()+data.columns());207 utility::Matrix* data_all = 208 new utility::Matrix(data.rows(), row_index_.size()+data.columns()); 209 209 210 210 for (size_t i=0; i<data_all->rows(); ++i) { … … 240 240 // kernel_ holds MatrixLookupWeighted, hence new Kernel also 241 241 // should hold a MatrixLookupweighted. 242 utility:: matrix* data_all =243 new utility:: matrix(data.rows(), rows()+data.columns());244 utility:: matrix* weight_all =245 new utility:: matrix(data.rows(), rows()+data.columns(), 1.0);242 utility::Matrix* data_all = 243 new utility::Matrix(data.rows(), rows()+data.columns()); 244 utility::Matrix* weight_all = 245 new utility::Matrix(data.rows(), rows()+data.columns(), 1.0); 246 246 const MatrixLookupWeighted& kernel_data = 247 247 dynamic_cast<const MatrixLookupWeighted&>(kernel_->data()); … … 281 281 KernelLookup::test_kernel(const MatrixLookupWeighted& data) const 282 282 { 283 utility:: matrix* data_all =284 new utility:: matrix(data.rows(), rows()+data.columns());285 utility:: matrix* weight_all =286 new utility:: matrix(data.rows(), rows()+data.columns(), 1.0);283 utility::Matrix* data_all = 284 new utility::Matrix(data.rows(), rows()+data.columns()); 285 utility::Matrix* weight_all = 286 new utility::Matrix(data.rows(), rows()+data.columns(), 1.0); 287 287 288 288 if (weighted()){ -
trunk/yat/classifier/Kernel_SEV.cc
r1098 r1121 28 28 #include "KernelFunction.h" 29 29 #include "MatrixLookup.h" 30 #include "yat/utility/ matrix.h"30 #include "yat/utility/Matrix.h" 31 31 32 32 namespace theplu { -
trunk/yat/classifier/Kernel_SEV.h
r1000 r1121 28 28 29 29 #include "Kernel.h" 30 #include "yat/utility/ matrix.h"30 #include "yat/utility/Matrix.h" 31 31 32 32 namespace theplu { … … 113 113 void build_kernel(void); 114 114 115 utility:: matrix kernel_matrix_;115 utility::Matrix kernel_matrix_; 116 116 117 117 }; // class Kernel_SEV -
trunk/yat/classifier/MatrixLookup.cc
r1105 r1121 25 25 26 26 #include "MatrixLookup.h" 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 29 29 #include <algorithm> … … 35 35 namespace classifier { 36 36 37 MatrixLookup::MatrixLookup(const utility:: matrix& data, const bool own)37 MatrixLookup::MatrixLookup(const utility::Matrix& data, const bool own) 38 38 : DataLookup2D(own), data_(&data) 39 39 { … … 48 48 49 49 50 MatrixLookup::MatrixLookup(const utility:: matrix& data,50 MatrixLookup::MatrixLookup(const utility::Matrix& data, 51 51 const std::vector<size_t>& row, 52 52 const std::vector<size_t>& col) … … 63 63 64 64 65 MatrixLookup::MatrixLookup(const utility:: matrix& data,65 MatrixLookup::MatrixLookup(const utility::Matrix& data, 66 66 const std::vector<size_t>& index, 67 67 const bool row) … … 136 136 : DataLookup2D(rows,columns) 137 137 { 138 data_ = new utility:: matrix(1,1,value);138 data_ = new utility::Matrix(1,1,value); 139 139 ref_count_= new u_int(1); 140 140 } … … 144 144 : DataLookup2D() 145 145 { 146 data_ = new utility:: matrix(is,sep);146 data_ = new utility::Matrix(is,sep); 147 147 ref_count_= new u_int(1); 148 148 for(size_t i=0;i<(*data_).rows();i++) -
trunk/yat/classifier/MatrixLookup.h
r1110 r1121 39 39 40 40 namespace utility { 41 class matrix;41 class Matrix; 42 42 } 43 43 … … 96 96 /// undefined. 97 97 /// 98 MatrixLookup(const utility:: matrix& matrix, const bool own=false);98 MatrixLookup(const utility::Matrix& matrix, const bool own=false); 99 99 100 100 /// … … 111 111 /// undefined. 112 112 /// 113 MatrixLookup(const utility:: matrix& matrix, const std::vector<size_t>& row,113 MatrixLookup(const utility::Matrix& matrix, const std::vector<size_t>& row, 114 114 const std::vector<size_t>& column); 115 115 … … 131 131 /// undefined. 132 132 /// 133 MatrixLookup(const utility:: matrix& matrix,133 MatrixLookup(const utility::Matrix& matrix, 134 134 const std::vector<size_t>& index, 135 135 const bool row_vectors); … … 330 330 friend class MatrixLookupWeighted; 331 331 332 const utility:: matrix* data_;332 const utility::Matrix* data_; 333 333 }; 334 334 -
trunk/yat/classifier/MatrixLookupWeighted.cc
r1105 r1121 25 25 #include "MatrixLookupWeighted.h" 26 26 #include "MatrixLookup.h" 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 29 29 #include <algorithm> … … 35 35 namespace classifier { 36 36 37 MatrixLookupWeighted::MatrixLookupWeighted(const utility:: matrix& data,38 const utility:: matrix& weights,37 MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data, 38 const utility::Matrix& weights, 39 39 const bool own) 40 40 : DataLookup2D(own), data_(&data), weights_(&weights), … … 50 50 51 51 52 MatrixLookupWeighted::MatrixLookupWeighted(const utility:: matrix& data)52 MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data) 53 53 : DataLookup2D(), data_(&data) 54 54 { 55 utility:: matrix weights;55 utility::Matrix weights; 56 56 utility::nan(*data_,weights); 57 weights_= new utility:: matrix(weights);57 weights_= new utility::Matrix(weights); 58 58 ref_count_weights_=new u_int(1); 59 59 for(size_t i=0;i<(*data_).rows();i++) … … 67 67 : DataLookup2D(ml), data_(ml.data_) 68 68 { 69 weights_= new utility:: matrix(data_->rows(), data_->columns(), 1.0);69 weights_= new utility::Matrix(data_->rows(), data_->columns(), 1.0); 70 70 ref_count_weights_=new u_int(1); 71 71 ref_count_=ml.ref_count_; … … 76 76 77 77 78 MatrixLookupWeighted::MatrixLookupWeighted(const utility:: matrix& data,79 const utility:: matrix& weights,78 MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data, 79 const utility::Matrix& weights, 80 80 const std::vector<size_t>& row, 81 81 const std::vector<size_t>& col) … … 99 99 100 100 101 MatrixLookupWeighted::MatrixLookupWeighted(const utility:: matrix& data,102 const utility:: matrix& weights,101 MatrixLookupWeighted::MatrixLookupWeighted(const utility::Matrix& data, 102 const utility::Matrix& weights, 103 103 const std::vector<size_t>& index, 104 104 const bool row) … … 209 209 : DataLookup2D(rows,columns) 210 210 { 211 data_ = new utility:: matrix(1,1,value);211 data_ = new utility::Matrix(1,1,value); 212 212 ref_count_=new u_int(1); 213 weights_ = new utility:: matrix(1,1,weight);213 weights_ = new utility::Matrix(1,1,weight); 214 214 ref_count_weights_=new u_int(1); 215 215 } … … 219 219 : DataLookup2D() 220 220 { 221 data_ = new utility:: matrix(is,sep);221 data_ = new utility::Matrix(is,sep); 222 222 ref_count_=new u_int(1); 223 223 for(size_t i=0;i<(*data_).rows();i++) … … 225 225 for(size_t i=0;i<(*data_).columns();i++) 226 226 column_index_.push_back(i); 227 utility:: matrix weights;227 utility::Matrix weights; 228 228 utility::nan(*data_,weights); 229 weights_= new utility:: matrix(weights);229 weights_= new utility::Matrix(weights); 230 230 ref_count_weights_=new u_int(1); 231 231 } -
trunk/yat/classifier/MatrixLookupWeighted.h
r1110 r1121 39 39 40 40 namespace utility { 41 class matrix;41 class Matrix; 42 42 } 43 43 … … 91 91 /// result of further use is undefined. 92 92 /// 93 MatrixLookupWeighted(const utility:: matrix& matrix,94 const utility:: matrix& weights,93 MatrixLookupWeighted(const utility::Matrix& matrix, 94 const utility::Matrix& weights, 95 95 const bool owner=false); 96 96 … … 107 107 /// result of further use is undefined. 108 108 /// 109 MatrixLookupWeighted(const utility:: matrix& matrix);109 MatrixLookupWeighted(const utility::Matrix& matrix); 110 110 111 111 … … 140 140 /// undefined. 141 141 /// 142 MatrixLookupWeighted(const utility:: matrix& matrix,143 const utility:: matrix& weights,142 MatrixLookupWeighted(const utility::Matrix& matrix, 143 const utility::Matrix& weights, 144 144 const std::vector<size_t>& row, 145 145 const std::vector<size_t>& column); … … 163 163 /// result of further use is undefined. 164 164 /// 165 MatrixLookupWeighted(const utility:: matrix& matrix,166 const utility:: matrix& weights,165 MatrixLookupWeighted(const utility::Matrix& matrix, 166 const utility::Matrix& weights, 167 167 const std::vector<size_t>& index, 168 168 const bool row_vectors); … … 368 368 369 369 private: 370 const utility:: matrix* data_;371 const utility:: matrix* weights_;370 const utility::Matrix* data_; 371 const utility::Matrix* weights_; 372 372 u_int* ref_count_weights_; 373 373 }; -
trunk/yat/classifier/NBC.cc
r1120 r1121 29 29 #include "Target.h" 30 30 #include "yat/statistics/AveragerWeighted.h" 31 #include "yat/utility/ matrix.h"31 #include "yat/utility/Matrix.h" 32 32 33 33 #include <cassert> … … 86 86 sigma2_.resize(data_.rows(), target_.nof_classes()); 87 87 centroids_.resize(data_.rows(), target_.nof_classes()); 88 utility:: matrix nof_in_class(data_.rows(), target_.nof_classes());88 utility::Matrix nof_in_class(data_.rows(), target_.nof_classes()); 89 89 90 90 // unweighted … … 144 144 145 145 void NBC::predict(const DataLookup2D& x, 146 utility:: matrix& prediction) const146 utility::Matrix& prediction) const 147 147 { 148 148 assert(data_.rows()==x.rows()); -
trunk/yat/classifier/NBC.h
r1042 r1121 27 27 28 28 #include "SupervisedClassifier.h" 29 #include "yat/utility/ matrix.h"29 #include "yat/utility/Matrix.h" 30 30 31 31 namespace theplu { … … 99 99 using all weight equal to unity. 100 100 */ 101 void predict(const DataLookup2D& data, utility:: matrix& res) const;101 void predict(const DataLookup2D& data, utility::Matrix& res) const; 102 102 103 103 104 104 private: 105 utility:: matrix centroids_;106 utility:: matrix sigma2_;105 utility::Matrix centroids_; 106 utility::Matrix sigma2_; 107 107 const DataLookup2D& data_; 108 108 -
trunk/yat/classifier/NCC.h
r1120 r1121 37 37 #include "yat/statistics/Averager.h" 38 38 #include "yat/statistics/AveragerWeighted.h" 39 #include "yat/utility/ matrix.h"39 #include "yat/utility/Matrix.h" 40 40 #include "yat/utility/Vector.h" 41 41 #include "yat/utility/stl_utility.h" … … 81 81 /// @return the centroids for each class as columns in a matrix. 82 82 /// 83 const utility:: matrix& centroids(void) const;83 const utility::Matrix& centroids(void) const; 84 84 85 85 const DataLookup2D& data(void) const; … … 100 100 /// Calculate the distance to each centroid for test samples 101 101 /// 102 void predict(const DataLookup2D&, utility:: matrix&) const;102 void predict(const DataLookup2D&, utility::Matrix&) const; 103 103 104 104 105 105 private: 106 106 107 void predict_unweighted(const MatrixLookup&, utility:: matrix&) const;108 void predict_weighted(const MatrixLookupWeighted&, utility:: matrix&) const;109 110 utility:: matrix* centroids_;107 void predict_unweighted(const MatrixLookup&, utility::Matrix&) const; 108 void predict_weighted(const MatrixLookupWeighted&, utility::Matrix&) const; 109 110 utility::Matrix* centroids_; 111 111 bool centroids_nan_; 112 112 Distance distance_; … … 145 145 146 146 template <typename Distance> 147 const utility:: matrix& NCC<Distance>::centroids(void) const147 const utility::Matrix& NCC<Distance>::centroids(void) const 148 148 { 149 149 return *centroids_; … … 185 185 if(centroids_) 186 186 delete centroids_; 187 centroids_= new utility:: matrix(data_.rows(), target_.nof_classes());187 centroids_= new utility::Matrix(data_.rows(), target_.nof_classes()); 188 188 // data_ is a MatrixLookup or a MatrixLookupWeighted 189 189 if(data_.weighted()) { … … 226 226 template <typename Distance> 227 227 void NCC<Distance>::predict(const DataLookup2D& test, 228 utility:: matrix& prediction) const228 utility::Matrix& prediction) const 229 229 { 230 230 utility::yat_assert<std::runtime_error> … … 262 262 template <typename Distance> 263 263 void NCC<Distance>::predict_unweighted(const MatrixLookup& test, 264 utility:: matrix& prediction) const264 utility::Matrix& prediction) const 265 265 { 266 266 MatrixLookup unweighted_centroids(*centroids_); … … 277 277 template <typename Distance> 278 278 void NCC<Distance>::predict_weighted(const MatrixLookupWeighted& test, 279 utility:: matrix& prediction) const279 utility::Matrix& prediction) const 280 280 { 281 281 MatrixLookupWeighted weighted_centroids(*centroids_); -
trunk/yat/classifier/SVM.cc
r1120 r1121 29 29 #include "yat/random/random.h" 30 30 #include "yat/statistics/Averager.h" 31 #include "yat/utility/ matrix.h"31 #include "yat/utility/Matrix.h" 32 32 #include "yat/utility/Vector.h" 33 33 … … 139 139 } 140 140 141 void SVM::predict(const KernelLookup& input, utility:: matrix& prediction) const141 void SVM::predict(const KernelLookup& input, utility::Matrix& prediction) const 142 142 { 143 143 assert(input.rows()==alpha_.size()); -
trunk/yat/classifier/SVM.h
r1120 r1121 36 36 namespace theplu { 37 37 namespace yat { 38 namespace utility{ 39 class Matrix; 40 } 41 38 42 namespace classifier { 39 43 … … 133 137 for training. 134 138 */ 135 void predict(const KernelLookup& input, utility:: matrix& predict) const;139 void predict(const KernelLookup& input, utility::Matrix& predict) const; 136 140 137 141 /// -
trunk/yat/classifier/SVindex.cc
r1120 r1121 26 26 #include "yat/random/random.h" 27 27 #include "yat/statistics/Averager.h" 28 #include "yat/utility/matrix.h"29 28 #include "yat/utility/Vector.h" 30 29 -
trunk/yat/classifier/SupervisedClassifier.h
r1042 r1121 33 33 34 34 namespace utility { 35 class matrix;35 class Matrix; 36 36 } 37 37 … … 82 82 /// Generate output values for a data set 83 83 /// 84 virtual void predict(const DataLookup2D&, utility:: matrix&) const =0;84 virtual void predict(const DataLookup2D&, utility::Matrix&) const =0; 85 85 86 86 -
trunk/yat/regression/MultiDimensional.cc
r1120 r1121 25 25 #include "MultiDimensional.h" 26 26 #include "yat/utility/Exception.h" 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 #include "yat/utility/VectorBase.h" 29 29 #include "yat/utility/Vector.h" … … 49 49 50 50 51 const utility:: matrix& MultiDimensional::covariance(void) const51 const utility::Matrix& MultiDimensional::covariance(void) const 52 52 { 53 53 return covariance_; … … 55 55 56 56 57 void MultiDimensional::fit(const utility:: matrix& x,57 void MultiDimensional::fit(const utility::Matrix& x, 58 58 const utility::VectorBase& y) 59 59 { -
trunk/yat/regression/MultiDimensional.h
r1120 r1121 25 25 */ 26 26 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 #include "yat/utility/VectorBase.h" 29 29 … … 54 54 /// @brief covariance of parameters 55 55 /// 56 const utility:: matrix& covariance(void) const;56 const utility::Matrix& covariance(void) const; 57 57 58 58 /** … … 64 64 dimension errors). 65 65 */ 66 void fit(const utility:: matrix& X, const utility::VectorBase& y);66 void fit(const utility::Matrix& X, const utility::VectorBase& y); 67 67 68 68 /// … … 95 95 double chisquare_; 96 96 double s2_; 97 utility:: matrix covariance_;97 utility::Matrix covariance_; 98 98 utility::Vector fit_parameters_; 99 99 gsl_multifit_linear_workspace* work_; -
trunk/yat/regression/MultiDimensionalWeighted.cc
r1120 r1121 24 24 #include "MultiDimensionalWeighted.h" 25 25 #include "yat/statistics/AveragerWeighted.h" 26 #include "yat/utility/ matrix.h"26 #include "yat/utility/Matrix.h" 27 27 #include "yat/utility/Vector.h" 28 28 … … 51 51 52 52 53 void MultiDimensionalWeighted::fit(const utility:: matrix& x,53 void MultiDimensionalWeighted::fit(const utility::Matrix& x, 54 54 const utility::VectorBase& y, 55 55 const utility::VectorBase& w) -
trunk/yat/regression/MultiDimensionalWeighted.h
r1120 r1121 25 25 */ 26 26 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 #include "yat/utility/Vector.h" 29 29 … … 63 63 dimension errors). 64 64 */ 65 void fit(const utility:: matrix& X, const utility::VectorBase& y,65 void fit(const utility::Matrix& X, const utility::VectorBase& y, 66 66 const utility::VectorBase& w); 67 67 … … 94 94 private: 95 95 double chisquare_; 96 utility:: matrix covariance_;96 utility::Matrix covariance_; 97 97 utility::Vector fit_parameters_; 98 98 double s2_; -
trunk/yat/regression/Polynomial.cc
r1120 r1121 25 25 26 26 #include "Polynomial.h" 27 #include "yat/utility/ matrix.h"27 #include "yat/utility/Matrix.h" 28 28 #include "yat/utility/VectorBase.h" 29 29 … … 43 43 44 44 45 const utility:: matrix& Polynomial::covariance(void) const45 const utility::Matrix& Polynomial::covariance(void) const 46 46 { 47 47 return md_.covariance(); … … 53 53 { 54 54 add(ap_, x.begin(), x.end(), y.begin()); 55 utility:: matrix X=utility::matrix(x.size(),power_+1,1);55 utility::Matrix X=utility::Matrix(x.size(),power_+1,1); 56 56 for (size_t i=0; i<X.rows(); ++i) 57 57 for (u_int j=1; j<X.columns(); j++) -
trunk/yat/regression/Polynomial.h
r1120 r1121 59 59 /// @brief covariance of parameters 60 60 /// 61 const utility:: matrix& covariance(void) const;61 const utility::Matrix& covariance(void) const; 62 62 63 63 /// -
trunk/yat/regression/PolynomialWeighted.cc
r1120 r1121 24 24 25 25 #include "PolynomialWeighted.h" 26 #include "yat/utility/ matrix.h"26 #include "yat/utility/Matrix.h" 27 27 #include "yat/utility/Vector.h" 28 28 … … 54 54 utility::Vector dummy(x.size(), 1.0); 55 55 add(ap_,x.begin(), x.end(),y.begin(),dummy.begin(),w.begin()); 56 utility:: matrix X=utility::matrix(x.size(),power_+1,1);56 utility::Matrix X=utility::Matrix(x.size(),power_+1,1); 57 57 for (size_t i=0; i<X.rows(); ++i) 58 58 for (u_int j=1; j<X.columns(); j++) -
trunk/yat/utility/Alignment.cc
r1120 r1121 25 25 26 26 #include "Alignment.h" 27 #include " matrix.h"27 #include "Matrix.h" 28 28 #include "stl_utility.h" 29 29 … … 36 36 namespace utility { 37 37 38 double NeedlemanWunsch(const utility:: matrix& s,38 double NeedlemanWunsch(const utility::Matrix& s, 39 39 std::vector<std::pair<size_t, size_t> >& path, 40 40 const double gap) 41 41 { 42 utility:: matrix m(s.rows()+1,s.columns()+1);42 utility::Matrix m(s.rows()+1,s.columns()+1); 43 43 // Init upper and left border of matrix 44 44 for (size_t i=1; i<m.rows(); i++) … … 48 48 // choice(i,j) tells us how we came to s(i,j). 1 is diagonal, 2 49 49 // vertical, and 3 horizontal, 50 utility:: matrix choice(m.rows(),m.columns());50 utility::Matrix choice(m.rows(),m.columns()); 51 51 52 52 // Calculating NeedlemanWunsch matrix … … 90 90 double open_gap) 91 91 { 92 matrix m(first.size(), second.size());92 Matrix m(first.size(), second.size()); 93 93 for (size_t i=0; i<first.size(); ++i) 94 94 for (size_t j=0; j<second.size(); ++j) … … 98 98 99 99 100 double SmithWaterman(const utility:: matrix& s,100 double SmithWaterman(const utility::Matrix& s, 101 101 double gap, double open_gap) 102 102 { … … 104 104 105 105 // Calculating S-W matrix 106 matrix m(s.rows()+1,s.columns()+1);107 matrix array(m);106 Matrix m(s.rows()+1,s.columns()+1); 107 Matrix array(m); 108 108 for (size_t i=1; i<m.rows(); ++i) 109 109 for (size_t j=1; j<m.columns(); ++j){ -
trunk/yat/utility/Alignment.h
r1000 r1121 35 35 namespace utility { 36 36 37 class matrix;37 class Matrix; 38 38 39 39 /// … … 57 57 /// @return the global maximum alignment score. 58 58 /// 59 double NeedlemanWunsch(const utility:: matrix& s,59 double NeedlemanWunsch(const utility::Matrix& s, 60 60 std::vector<std::pair<size_t, size_t> >& path, 61 61 const double gap); … … 78 78 gap of length \f$l\f$ the total cost is \f$open_gap + l*gap\f$. 79 79 */ 80 double SmithWaterman(const utility:: matrix& s,80 double SmithWaterman(const utility::Matrix& s, 81 81 double gap, double open_gap); 82 82 -
trunk/yat/utility/Makefile.am
r1120 r1121 27 27 libutility_la_SOURCES = \ 28 28 Alignment.cc ColumnStream.cc CommandLine.cc FileUtil.cc Index.cc kNNI.cc \ 29 matrix.cc NNI.cc Option.cc OptionFile.cc OptionInFile.cc OptionOutFile.cc \29 Matrix.cc NNI.cc Option.cc OptionFile.cc OptionInFile.cc OptionOutFile.cc \ 30 30 OptionHelp.cc OptionSwitch.cc \ 31 31 PCA.cc stl_utility.cc SVD.cc TypeInfo.cc utility.cc Vector.cc \ … … 38 38 Container2DIterator.h \ 39 39 Exception.h FileUtil.h Index.h IteratorPolicy.h iterator_traits.h \ 40 kNNI.h matrix.h NNI.h \40 kNNI.h Matrix.h NNI.h \ 41 41 Option.h OptionArg.h OptionFile.h OptionInFile.h OptionOutFile.h \ 42 42 OptionHelp.h OptionSwitch.h \ -
trunk/yat/utility/Matrix.cc
r1120 r1121 25 25 */ 26 26 27 #include " yat/utility/matrix.h"28 #include " yat/utility/Vector.h"27 #include "Matrix.h" 28 #include "Vector.h" 29 29 #include "VectorBase.h" 30 30 #include "VectorConstView.h" … … 44 44 45 45 46 matrix::matrix(void)46 Matrix::Matrix(void) 47 47 : blas_result_(NULL), m_(NULL) 48 48 { … … 50 50 51 51 52 matrix::matrix(const size_t& r, const size_t& c, double init_value)52 Matrix::Matrix(const size_t& r, const size_t& c, double init_value) 53 53 : blas_result_(NULL), m_(gsl_matrix_alloc(r,c)) 54 54 { 55 55 if (!m_) 56 throw utility::GSL_error(" matrix::matrix failed to allocate memory");56 throw utility::GSL_error("Matrix::Matrix failed to allocate memory"); 57 57 all(init_value); 58 58 } 59 59 60 60 61 matrix::matrix(const matrix& o)61 Matrix::Matrix(const Matrix& o) 62 62 : blas_result_(NULL), m_(o.create_gsl_matrix_copy()) 63 63 { … … 66 66 67 67 // Constructor that gets data from istream 68 matrix::matrix(std::istream& is, char sep)68 Matrix::Matrix(std::istream& is, char sep) 69 69 throw (utility::IO_error,std::exception) 70 70 : blas_result_(NULL) … … 113 113 else if (v.size()!=nof_columns) { 114 114 std::ostringstream s; 115 s << " matrix::matrix(std::istream&, char) data file error: "115 s << "Matrix::Matrix(std::istream&, char) data file error: " 116 116 << "line " << nof_rows << " has " << v.size() 117 117 << " columns; expected " << nof_columns << " columns."; … … 126 126 m_ = gsl_matrix_alloc ( nof_rows, nof_columns ); 127 127 if (!m_) 128 throw utility::GSL_error(" matrix::matrix failed to allocate memory");128 throw utility::GSL_error("Matrix::Matrix failed to allocate memory"); 129 129 130 130 // if gsl error handler disabled, out of bounds index will not … … 136 136 137 137 138 matrix::~matrix(void)138 Matrix::~Matrix(void) 139 139 { 140 140 delete_allocated_memory(); … … 145 145 146 146 147 void matrix::all(const double value)147 void Matrix::all(const double value) 148 148 { 149 149 assert(m_); … … 152 152 153 153 154 matrix::iterator matrix::begin(void)154 Matrix::iterator Matrix::begin(void) 155 155 { 156 156 return iterator(&(*this)(0,0), 1); … … 158 158 159 159 160 matrix::const_iterator matrix::begin(void) const160 Matrix::const_iterator Matrix::begin(void) const 161 161 { 162 162 return const_iterator(&(*this)(0,0), 1); … … 164 164 165 165 166 matrix::column_iterator matrix::begin_column(size_t i)166 Matrix::column_iterator Matrix::begin_column(size_t i) 167 167 { 168 168 return iterator(&(*this)(0,i), this->columns()); … … 170 170 171 171 172 matrix::const_column_iterator matrix::begin_column(size_t i) const172 Matrix::const_column_iterator Matrix::begin_column(size_t i) const 173 173 { 174 174 return const_iterator(&(*this)(0,i), this->columns()); … … 176 176 177 177 178 matrix::row_iterator matrix::begin_row(size_t i)178 Matrix::row_iterator Matrix::begin_row(size_t i) 179 179 { 180 180 return iterator(&(*this)(i,0), 1); … … 182 182 183 183 184 matrix::const_row_iterator matrix::begin_row(size_t i) const184 Matrix::const_row_iterator Matrix::begin_row(size_t i) const 185 185 { 186 186 return const_iterator(&(*this)(i,0), 1); … … 188 188 189 189 190 VectorView matrix::column_view(size_t col)190 VectorView Matrix::column_view(size_t col) 191 191 { 192 192 VectorView res(*this, col, false); … … 195 195 196 196 197 const VectorConstView matrix::column_const_view(size_t col) const197 const VectorConstView Matrix::column_const_view(size_t col) const 198 198 { 199 199 return VectorConstView(*this, col, false); … … 201 201 202 202 203 size_t matrix::columns(void) const203 size_t Matrix::columns(void) const 204 204 { 205 205 return (m_ ? m_->size2 : 0); … … 207 207 208 208 209 gsl_matrix* matrix::create_gsl_matrix_copy(void) const209 gsl_matrix* Matrix::create_gsl_matrix_copy(void) const 210 210 { 211 211 gsl_matrix* m = gsl_matrix_alloc(rows(),columns()); 212 212 if (!m) 213 throw utility::GSL_error(" matrix::create_gsl_matrix_copy failed to allocate memory");213 throw utility::GSL_error("Matrix::create_gsl_matrix_copy failed to allocate memory"); 214 214 if (gsl_matrix_memcpy(m,m_)) 215 throw utility::GSL_error(" matrix::create_gsl_matrix_copy dimension mis-match");215 throw utility::GSL_error("Matrix::create_gsl_matrix_copy dimension mis-match"); 216 216 return m; 217 217 } 218 218 219 219 220 void matrix::delete_allocated_memory(void)220 void Matrix::delete_allocated_memory(void) 221 221 { 222 222 if (m_) … … 226 226 227 227 228 void matrix::div(const matrix& other)228 void Matrix::div(const Matrix& other) 229 229 { 230 230 assert(m_); … … 235 235 236 236 237 matrix::iterator matrix::end(void)237 Matrix::iterator Matrix::end(void) 238 238 { 239 239 return iterator(&(*this)(0,0)+rows()*columns(), 1); … … 241 241 242 242 243 matrix::const_iterator matrix::end(void) const243 Matrix::const_iterator Matrix::end(void) const 244 244 { 245 245 return const_iterator(&(*this)(0,0)+rows()*columns(), 1); … … 247 247 248 248 249 matrix::column_iterator matrix::end_column(size_t i)249 Matrix::column_iterator Matrix::end_column(size_t i) 250 250 { 251 251 return column_iterator(&(*this)(0,i)+rows()*columns(), this->columns()); … … 253 253 254 254 255 matrix::const_column_iterator matrix::end_column(size_t i) const255 Matrix::const_column_iterator Matrix::end_column(size_t i) const 256 256 { 257 257 return const_column_iterator(&(*this)(0,i)+rows()*columns(),this->columns()); … … 259 259 260 260 261 matrix::row_iterator matrix::end_row(size_t i)261 Matrix::row_iterator Matrix::end_row(size_t i) 262 262 { 263 263 return row_iterator(&(*this)(i,0)+columns(), 1); … … 265 265 266 266 267 matrix::const_row_iterator matrix::end_row(size_t i) const267 Matrix::const_row_iterator Matrix::end_row(size_t i) const 268 268 { 269 269 return const_row_iterator(&(*this)(i,0)+columns(), 1); … … 271 271 272 272 273 bool matrix::equal(const matrix& other, const double d) const273 bool Matrix::equal(const Matrix& other, const double d) const 274 274 { 275 275 if (this==&other) … … 287 287 288 288 289 const gsl_matrix* matrix::gsl_matrix_p(void) const289 const gsl_matrix* Matrix::gsl_matrix_p(void) const 290 290 { 291 291 return m_; … … 293 293 294 294 295 gsl_matrix* matrix::gsl_matrix_p(void)295 gsl_matrix* Matrix::gsl_matrix_p(void) 296 296 { 297 297 return m_; … … 299 299 300 300 301 void matrix::mul(const matrix& other)301 void Matrix::mul(const Matrix& other) 302 302 { 303 303 assert(m_); 304 304 int status=gsl_matrix_mul_elements(m_, other.gsl_matrix_p()); 305 305 if (status) 306 throw utility::GSL_error(std::string(" matrix::mul_elements",status));307 } 308 309 310 void matrix::resize(size_t r, size_t c, double init_value)306 throw utility::GSL_error(std::string("Matrix::mul_elements",status)); 307 } 308 309 310 void Matrix::resize(size_t r, size_t c, double init_value) 311 311 { 312 312 delete_allocated_memory(); … … 314 314 m_ = gsl_matrix_alloc(r,c); 315 315 if (!m_) 316 throw utility::GSL_error(" matrix::matrix failed to allocate memory");316 throw utility::GSL_error("Matrix::Matrix failed to allocate memory"); 317 317 all(init_value); 318 318 … … 326 326 327 327 328 size_t matrix::rows(void) const328 size_t Matrix::rows(void) const 329 329 { 330 330 return (m_ ? m_->size1 : 0); … … 332 332 333 333 334 const VectorConstView matrix::row_const_view(size_t col) const334 const VectorConstView Matrix::row_const_view(size_t col) const 335 335 { 336 336 return VectorConstView(*this, col, true); … … 338 338 339 339 340 VectorView matrix::row_view(size_t row)340 VectorView Matrix::row_view(size_t row) 341 341 { 342 342 VectorView res(*this, row, true); … … 345 345 346 346 347 void matrix::swap_columns(const size_t i, const size_t j)347 void Matrix::swap_columns(const size_t i, const size_t j) 348 348 { 349 349 assert(m_); 350 350 int status=gsl_matrix_swap_columns(m_, i, j); 351 351 if (status) 352 throw utility::GSL_error(std::string(" matrix::swap_columns",status));353 } 354 355 356 void matrix::swap_rowcol(const size_t i, const size_t j)352 throw utility::GSL_error(std::string("Matrix::swap_columns",status)); 353 } 354 355 356 void Matrix::swap_rowcol(const size_t i, const size_t j) 357 357 { 358 358 assert(m_); 359 359 int status=gsl_matrix_swap_rowcol(m_, i, j); 360 360 if (status) 361 throw utility::GSL_error(std::string(" matrix::swap_rowcol",status));362 } 363 364 365 void matrix::swap_rows(const size_t i, const size_t j)361 throw utility::GSL_error(std::string("Matrix::swap_rowcol",status)); 362 } 363 364 365 void Matrix::swap_rows(const size_t i, const size_t j) 366 366 { 367 367 assert(m_); 368 368 int status=gsl_matrix_swap_rows(m_, i, j); 369 369 if (status) 370 throw utility::GSL_error(std::string(" matrix::swap_rows",status));371 } 372 373 374 void matrix::transpose(void)370 throw utility::GSL_error(std::string("Matrix::swap_rows",status)); 371 } 372 373 374 void Matrix::transpose(void) 375 375 { 376 376 assert(m_); … … 380 380 gsl_matrix* transposed = gsl_matrix_alloc(columns(),rows()); 381 381 if (!transposed) 382 throw utility::GSL_error(" matrix::transpose failed to allocate memory");382 throw utility::GSL_error("Matrix::transpose failed to allocate memory"); 383 383 // next line never fails if allocation above succeeded. 384 384 gsl_matrix_transpose_memcpy(transposed,m_); … … 393 393 394 394 395 double& matrix::operator()(size_t row, size_t column)395 double& Matrix::operator()(size_t row, size_t column) 396 396 { 397 397 assert(m_); … … 400 400 double* d=gsl_matrix_ptr(m_, row, column); 401 401 if (!d) 402 throw utility::GSL_error(" matrix::operator()",GSL_EINVAL);402 throw utility::GSL_error("Matrix::operator()",GSL_EINVAL); 403 403 return *d; 404 404 } 405 405 406 406 407 const double& matrix::operator()(size_t row, size_t column) const407 const double& Matrix::operator()(size_t row, size_t column) const 408 408 { 409 409 assert(row<rows()); … … 411 411 const double* d=gsl_matrix_const_ptr(m_, row, column); 412 412 if (!d) 413 throw utility::GSL_error(" matrix::operator()",GSL_EINVAL);413 throw utility::GSL_error("Matrix::operator()",GSL_EINVAL); 414 414 return *d; 415 415 } 416 416 417 417 418 bool matrix::operator==(const matrix& other) const418 bool Matrix::operator==(const Matrix& other) const 419 419 { 420 420 return equal(other); … … 422 422 423 423 424 bool matrix::operator!=(const matrix& other) const424 bool Matrix::operator!=(const Matrix& other) const 425 425 { 426 426 return !equal(other); … … 428 428 429 429 430 const matrix& matrix::operator=( const matrix& other )430 const Matrix& Matrix::operator=( const Matrix& other ) 431 431 { 432 432 assert(other.m_); … … 435 435 resize(other.m_->size1,other.m_->size2); 436 436 if (gsl_matrix_memcpy(m_, other.gsl_matrix_p())) 437 throw utility::GSL_error(" matrix::create_gsl_matrix_copy dimension mis-match");437 throw utility::GSL_error("Matrix::create_gsl_matrix_copy dimension mis-match"); 438 438 } 439 439 return *this; … … 441 441 442 442 443 const matrix& matrix::operator+=(const matrix& other)443 const Matrix& Matrix::operator+=(const Matrix& other) 444 444 { 445 445 assert(m_); 446 446 int status=gsl_matrix_add(m_, other.m_); 447 447 if (status) 448 throw utility::GSL_error(std::string(" matrix::operator+=", status));449 return *this; 450 } 451 452 453 const matrix& matrix::operator+=(const double d)448 throw utility::GSL_error(std::string("Matrix::operator+=", status)); 449 return *this; 450 } 451 452 453 const Matrix& Matrix::operator+=(const double d) 454 454 { 455 455 assert(m_); … … 459 459 460 460 461 const matrix& matrix::operator-=(const matrix& other)461 const Matrix& Matrix::operator-=(const Matrix& other) 462 462 { 463 463 assert(m_); 464 464 int status=gsl_matrix_sub(m_, other.m_); 465 465 if (status) 466 throw utility::GSL_error(std::string(" matrix::operator-=", status));467 return *this; 468 } 469 470 471 const matrix& matrix::operator-=(const double d)466 throw utility::GSL_error(std::string("Matrix::operator-=", status)); 467 return *this; 468 } 469 470 471 const Matrix& Matrix::operator-=(const double d) 472 472 { 473 473 assert(m_); … … 477 477 478 478 479 const matrix& matrix::operator*=(const matrix& other)479 const Matrix& Matrix::operator*=(const Matrix& other) 480 480 { 481 481 assert(m_); … … 488 488 blas_result_ = gsl_matrix_alloc(rows(),other.columns()); 489 489 if (!blas_result_) 490 throw utility::GSL_error(" matrix::operator*= failed to allocate memory");490 throw utility::GSL_error("Matrix::operator*= failed to allocate memory"); 491 491 } 492 492 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, m_, other.m_, 0.0, blas_result_); … … 498 498 499 499 500 const matrix& matrix::operator*=(const double d)500 const Matrix& Matrix::operator*=(const double d) 501 501 { 502 502 assert(m_); … … 506 506 507 507 508 bool isnull(const matrix& other)508 bool isnull(const Matrix& other) 509 509 { 510 510 return gsl_matrix_isnull(other.gsl_matrix_p()); … … 512 512 513 513 514 double max(const matrix& other)514 double max(const Matrix& other) 515 515 { 516 516 return gsl_matrix_max(other.gsl_matrix_p()); … … 518 518 519 519 520 double min(const matrix& other)520 double min(const Matrix& other) 521 521 { 522 522 return gsl_matrix_min(other.gsl_matrix_p()); … … 524 524 525 525 526 void minmax_index(const matrix& other,526 void minmax_index(const Matrix& other, 527 527 std::pair<size_t,size_t>& min, std::pair<size_t,size_t>& max) 528 528 { … … 532 532 533 533 534 bool nan(const matrix& templat, matrix& flag)534 bool nan(const Matrix& templat, Matrix& flag) 535 535 { 536 536 size_t rows=templat.rows(); … … 551 551 552 552 553 void swap( matrix& a, matrix& b)553 void swap(Matrix& a, Matrix& b) 554 554 { 555 555 assert(a.gsl_matrix_p()); assert(b.gsl_matrix_p()); 556 556 int status=gsl_matrix_swap(a.gsl_matrix_p(), b.gsl_matrix_p()); 557 557 if (status) 558 throw utility::GSL_error(std::string("swap( matrix&,matrix&)",status));559 } 560 561 562 std::ostream& operator<<(std::ostream& s, const matrix& m)558 throw utility::GSL_error(std::string("swap(Matrix&,Matrix&)",status)); 559 } 560 561 562 std::ostream& operator<<(std::ostream& s, const Matrix& m) 563 563 { 564 564 s.setf(std::ios::dec); … … 576 576 577 577 578 Vector operator*(const matrix& m, const VectorBase& v)578 Vector operator*(const Matrix& m, const VectorBase& v) 579 579 { 580 580 utility::Vector res(m.rows()); … … 585 585 586 586 587 Vector operator*(const VectorBase& v, const matrix& m)587 Vector operator*(const VectorBase& v, const Matrix& m) 588 588 { 589 589 utility::Vector res(m.columns()); -
trunk/yat/utility/Matrix.h
r1120 r1121 62 62 /// superdiagonals. 63 63 /// 64 class matrix64 class Matrix 65 65 { 66 66 public: … … 95 95 structures. 96 96 */ 97 matrix(void);97 Matrix(void); 98 98 99 99 /** … … 103 103 \throw GSL_error if memory allocation fails. 104 104 */ 105 matrix(const size_t& r, const size_t& c, double init_value=0);105 Matrix(const size_t& r, const size_t& c, double init_value=0); 106 106 107 107 /** … … 111 111 fails. 112 112 */ 113 matrix(const matrix&);113 Matrix(const Matrix&); 114 114 115 115 /** … … 127 127 unexpected input is found in the input stream. 128 128 */ 129 explicit matrix(std::istream &, char sep='\0')129 explicit Matrix(std::istream &, char sep='\0') 130 130 throw(utility::IO_error, std::exception); 131 131 … … 133 133 \brief The destructor. 134 134 */ 135 ~ matrix(void);135 ~Matrix(void); 136 136 137 137 /// … … 206 206 \throw GSL_error if dimensions mis-match. 207 207 */ 208 void div(const matrix& b);208 void div(const Matrix& b); 209 209 210 210 /** … … 247 247 \see operator== and operator!= 248 248 */ 249 bool equal(const matrix&, const double precision=0) const;249 bool equal(const Matrix&, const double precision=0) const; 250 250 251 251 /// … … 260 260 261 261 /** 262 Multiply the elements of matrix \a b with the elements of the263 calling matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j264 \f$. The result is stored into the calling matrix.262 Multiply the elements of Matrix \a b with the elements of the 263 calling Matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j 264 \f$. The result is stored into the calling Matrix. 265 265 266 266 \throw GSL_error if dimensions mis-match. 267 267 */ 268 void mul(const matrix& b);269 270 /** 271 \brief Resize matrix268 void mul(const Matrix& b); 269 270 /** 271 \brief Resize Matrix 272 272 273 273 All elements are set to @a init_value. 274 274 275 275 \note underlying GSL matrix is destroyed and views into this 276 matrix becomes invalid.276 Matrix becomes invalid. 277 277 */ 278 278 void resize(size_t, size_t, double init_value=0); … … 303 303 \brief Swap row \a i and column \a j. 304 304 305 The matrix must be square.305 The Matrix must be square. 306 306 307 307 \throw GSL_error if either index is out of bounds, or if matrix … … 359 359 \see equal 360 360 */ 361 bool operator==(const matrix& other) const;361 bool operator==(const Matrix& other) const; 362 362 363 363 /** … … 372 372 \see equal 373 373 */ 374 bool operator!=(const matrix& other) const;374 bool operator!=(const Matrix& other) const; 375 375 376 376 /** 377 377 \brief The assignment operator. 378 378 379 \return A const reference to the resulting matrix.380 */ 381 const matrix& operator=(const matrix& other);379 \return A const reference to the resulting Matrix. 380 */ 381 const Matrix& operator=(const Matrix& other); 382 382 383 383 /** 384 384 \brief Add and assign operator. 385 385 386 Elementwise addition of the elements of matrix \a b to the left387 hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j386 Elementwise addition of the elements of Matrix \a b to the left 387 hand side Matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j 388 388 \f$. 389 389 390 \return A const reference to the resulting matrix.390 \return A const reference to the resulting Matrix. 391 391 392 392 \throw GSL_error if dimensions mis-match. 393 393 */ 394 const matrix& operator+=(const matrix& b);394 const Matrix& operator+=(const Matrix& b); 395 395 396 396 /** 397 397 \brief Add and assign operator 398 398 399 Add the scalar value \a d to the left hand side matrix, \f$399 Add the scalar value \a d to the left hand side Matrix, \f$ 400 400 a_{ij} = a_{ij} + d \; \forall i,j \f$. 401 401 */ 402 const matrix& operator+=(const double d);402 const Matrix& operator+=(const double d); 403 403 404 404 /** 405 405 \brief Subtract and assign operator. 406 406 407 Elementwise subtraction of the elements of matrix \a b to the408 left hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall407 Elementwise subtraction of the elements of Matrix \a b to the 408 left hand side Matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall 409 409 i,j \f$. 410 410 411 \return A const reference to the resulting matrix.411 \return A const reference to the resulting Matrix. 412 412 413 413 \throw GSL_error if dimensions mis-match. 414 414 */ 415 const matrix& operator-=(const matrix&);415 const Matrix& operator-=(const Matrix&); 416 416 417 417 /** 418 418 \brief Subtract and assign operator 419 419 420 Subtract the scalar value \a d to the left hand side matrix,420 Subtract the scalar value \a d to the left hand side Matrix, 421 421 \f$ a_{ij} = a_{ij} + d \; \forall i,j \f$. 422 422 */ 423 const matrix& operator-=(const double d);423 const Matrix& operator-=(const double d); 424 424 425 425 /** 426 426 \brief Multiply and assigment operator. 427 427 428 \return Const reference to the resulting matrix.428 \return Const reference to the resulting Matrix. 429 429 430 430 \throw GSL_error if memory allocation fails. 431 431 */ 432 const matrix& operator*=(const matrix&);432 const Matrix& operator*=(const Matrix&); 433 433 434 434 /** 435 435 \brief Multiply and assignment operator 436 436 437 Multiply the elements of the left hand side matrix with a437 Multiply the elements of the left hand side Matrix with a 438 438 scalar \a d, \f$ a_{ij} = d * a_{ij} \; \forall i,j \f$. 439 439 440 440 \throw GSL_error if memory allocation fails. 441 441 */ 442 const matrix& operator*=(double d);442 const Matrix& operator*=(double d); 443 443 444 444 private: … … 473 473 474 474 /** 475 \brief Check if all elements of the matrix are zero.476 477 \return True if all elements in the matrix is zero, false475 \brief Check if all elements of the Matrix are zero. 476 477 \return True if all elements in the Matrix is zero, false 478 478 othwerwise. 479 479 */ 480 bool isnull(const matrix&);481 482 /** 483 \brief Get the maximum value of the matrix.484 485 \return The maximum value of the matrix.486 */ 487 double max(const matrix&);488 489 /** 490 \brief Get the minimum value of the matrix.491 492 \return The minimum value of the matrix.493 */ 494 double min(const matrix&);495 496 /** 497 \brief Locate the maximum and minumum element in the matrix.480 bool isnull(const Matrix&); 481 482 /** 483 \brief Get the maximum value of the Matrix. 484 485 \return The maximum value of the Matrix. 486 */ 487 double max(const Matrix&); 488 489 /** 490 \brief Get the minimum value of the Matrix. 491 492 \return The minimum value of the Matrix. 493 */ 494 double min(const Matrix&); 495 496 /** 497 \brief Locate the maximum and minumum element in the Matrix. 498 498 499 499 \return The indecies to the element with the minimum and maximum 500 values of the matrix, respectively.500 values of the Matrix, respectively. 501 501 502 502 \note Lower index has precedence (searching in row-major order). 503 503 */ 504 void minmax_index(const matrix&,504 void minmax_index(const Matrix&, 505 505 std::pair<size_t,size_t>& min, 506 506 std::pair<size_t,size_t>& max); 507 507 508 508 /** 509 \brief Create a matrix \a flag indicating NaN's in another matrix509 \brief Create a Matrix \a flag indicating NaN's in another Matrix 510 510 \a templat. 511 511 512 The \a flag matrix is changed to contain 1's and 0's only. A 1513 means that the corresponding element in the \a templat matrix is512 The \a flag Matrix is changed to contain 1's and 0's only. A 1 513 means that the corresponding element in the \a templat Matrix is 514 514 valid and a zero means that the corresponding element is a NaN. 515 515 516 \note Space for matrix \a flag is reallocated to fit the size of517 matrix \a templat if sizes mismatch.518 519 \return True if the \a templat matrix contains at least one NaN.520 */ 521 bool nan(const matrix& templat, matrix& flag);516 \note Space for Matrix \a flag is reallocated to fit the size of 517 Matrix \a templat if sizes mismatch. 518 519 \return True if the \a templat Matrix contains at least one NaN. 520 */ 521 bool nan(const Matrix& templat, Matrix& flag); 522 522 523 523 /** … … 528 528 \throw GSL_error if either index is out of bounds. 529 529 */ 530 void swap( matrix&, matrix&);531 532 /** 533 \brief The output operator for the matrix class.534 */ 535 std::ostream& operator<< (std::ostream& s, const matrix&);536 537 /** 538 \brief vector matrix multiplication530 void swap(Matrix&, Matrix&); 531 532 /** 533 \brief The output operator for the Matrix class. 534 */ 535 std::ostream& operator<< (std::ostream& s, const Matrix&); 536 537 /** 538 \brief vector Matrix multiplication 539 539 */ 540 Vector operator*(const matrix&, const VectorBase&);541 542 /** 543 \brief matrix vector multiplication540 Vector operator*(const Matrix&, const VectorBase&); 541 542 /** 543 \brief Matrix vector multiplication 544 544 */ 545 Vector operator*(const VectorBase&, const matrix&);545 Vector operator*(const VectorBase&, const Matrix&); 546 546 547 547 }}} // of namespace utility, yat, and theplu -
trunk/yat/utility/NNI.cc
r1000 r1121 38 38 // implementations here see the paper cited in the class definition 39 39 // documentation. 40 NNI::NNI(const utility:: matrix& matrix,const utility::matrix& weight,40 NNI::NNI(const utility::Matrix& matrix,const utility::Matrix& weight, 41 41 const u_int neighbours) 42 42 : data_(matrix), imputed_data_(matrix), neighbours_(neighbours), … … 75 75 76 76 77 const utility:: matrix& NNI::imputed_data(void) const77 const utility::Matrix& NNI::imputed_data(void) const 78 78 { 79 79 return imputed_data_; -
trunk/yat/utility/NNI.h
r1000 r1121 27 27 */ 28 28 29 #include " matrix.h"29 #include "Matrix.h" 30 30 31 31 #include <iostream> … … 88 88 /// algorithms. 89 89 /// 90 NNI(const utility:: matrix& matrix,const utility::matrix& weight,90 NNI(const utility::Matrix& matrix,const utility::Matrix& weight, 91 91 const u_int neighbours); 92 92 … … 103 103 /// @return A const reference to the modified data. 104 104 /// 105 const utility:: matrix& imputed_data(void) const;105 const utility::Matrix& imputed_data(void) const; 106 106 107 107 /// … … 124 124 /// original data matrix 125 125 /// 126 const utility:: matrix& data_;126 const utility::Matrix& data_; 127 127 128 128 /// 129 129 /// data after imputation 130 130 /// 131 utility:: matrix imputed_data_;131 utility::Matrix imputed_data_; 132 132 133 133 /// … … 144 144 /// weight matrix 145 145 /// 146 const utility:: matrix& weight_;146 const utility::Matrix& weight_; 147 147 }; 148 148 -
trunk/yat/utility/PCA.cc
r1120 r1121 40 40 41 41 42 PCA::PCA(const utility:: matrix& A)42 PCA::PCA(const utility::Matrix& A) 43 43 : A_(A) 44 44 { … … 53 53 54 54 55 const utility:: matrix& PCA::eigenvectors(void) const55 const utility::Matrix& PCA::eigenvectors(void) const 56 56 { 57 57 return eigenvectors_; … … 62 62 { 63 63 // Row-center the data matrix 64 utility:: matrix A_center( A_.rows(), A_.columns() );64 utility::Matrix A_center( A_.rows(), A_.columns() ); 65 65 this->row_center( A_center ); 66 66 … … 68 68 std::auto_ptr<SVD> pSVD( new SVD( A_center ) ); 69 69 pSVD->decompose(); 70 utility:: matrix U(pSVD->U());71 utility:: matrix V(pSVD->V());70 utility::Matrix U(pSVD->U()); 71 utility::Matrix V(pSVD->V()); 72 72 73 73 // Read the eigenvectors and eigenvalues … … 141 141 142 142 143 utility:: matrix PCA::projection(const utility::matrix& samples ) const143 utility::Matrix PCA::projection(const utility::Matrix& samples ) const 144 144 { 145 145 const size_t Ncol = samples.columns(); 146 146 const size_t Nrow = samples.rows(); 147 utility:: matrix projs( Ncol, Ncol );147 utility::Matrix projs( Ncol, Ncol ); 148 148 149 149 utility::Vector temp(samples.rows()); … … 189 189 // that is, A_ = A_ - M, where M is a matrix 190 190 // with the meanvalues of each row 191 void PCA::row_center(utility:: matrix& A_center)191 void PCA::row_center(utility::Matrix& A_center) 192 192 { 193 193 meanvalues_ = Vector(A_.rows()); -
trunk/yat/utility/PCA.h
r1120 r1121 29 29 */ 30 30 31 #include " matrix.h"31 #include "Matrix.h" 32 32 #include "Vector.h" 33 33 … … 56 56 should have been performed and no products. 57 57 */ 58 explicit PCA(const utility:: matrix&);58 explicit PCA(const utility::Matrix&); 59 59 60 60 /** … … 81 81 eigenvectors. 82 82 */ 83 const utility:: matrix& eigenvectors(void) const;83 const utility::Matrix& eigenvectors(void) const; 84 84 85 85 /** … … 90 90 spanned by the eigenvectors. 91 91 */ 92 utility:: matrix projection( const utility::matrix& ) const;92 utility::Matrix projection( const utility::Matrix& ) const; 93 93 94 94 /** … … 116 116 with the meanvalues of each row 117 117 */ 118 void row_center( utility:: matrix& A_center );118 void row_center( utility::Matrix& A_center ); 119 119 120 utility:: matrix A_;120 utility::Matrix A_; 121 121 utility::Vector eigenvalues_; 122 utility:: matrix eigenvectors_;122 utility::Matrix eigenvectors_; 123 123 utility::Vector meanvalues_; 124 124 }; -
trunk/yat/utility/SVD.cc
r1120 r1121 36 36 37 37 38 SVD::SVD(const utility:: matrix& Ain)38 SVD::SVD(const utility::Matrix& Ain) 39 39 : U_(Ain), V_(Ain.columns(),Ain.columns()), s_(Ain.columns()) 40 40 { … … 88 88 { 89 89 utility::Vector w(U_.columns()); 90 utility:: matrix X(U_.columns(),U_.columns());90 utility::Matrix X(U_.columns(),U_.columns()); 91 91 return gsl_linalg_SV_decomp_mod(U_.gsl_matrix_p(), X.gsl_matrix_p(), 92 92 V_.gsl_matrix_p(), s_.gsl_vector_p(), … … 111 111 112 112 113 const utility:: matrix& SVD::U(void) const113 const utility::Matrix& SVD::U(void) const 114 114 { 115 115 return U_; … … 117 117 118 118 119 const utility:: matrix& SVD::V(void) const119 const utility::Matrix& SVD::V(void) const 120 120 { 121 121 return V_; -
trunk/yat/utility/SVD.h
r1120 r1121 29 29 */ 30 30 31 #include " matrix.h"31 #include "Matrix.h" 32 32 #include "Vector.h" 33 33 … … 80 80 object. 81 81 */ 82 SVD(const utility:: matrix& Ain);82 SVD(const utility::Matrix& Ain); 83 83 84 84 /** … … 124 124 is undefined. 125 125 */ 126 const utility:: matrix& U(void) const;126 const utility::Matrix& U(void) const; 127 127 128 128 /** … … 134 134 is undefined. 135 135 */ 136 const utility:: matrix& V(void) const;136 const utility::Matrix& V(void) const; 137 137 138 138 private: … … 158 158 int modified_golub_reinsch(void); 159 159 160 utility:: matrix U_, V_;160 utility::Matrix U_, V_; 161 161 utility::Vector s_; 162 162 }; -
trunk/yat/utility/Vector.cc
r1120 r1121 26 26 27 27 #include "Vector.h" 28 #include "matrix.h"29 28 #include "utility.h" 30 29 #include "yat/random/random.h" -
trunk/yat/utility/VectorBase.cc
r1120 r1121 26 26 27 27 #include "VectorBase.h" 28 #include " matrix.h"28 #include "Vector.h" 29 29 #include "utility.h" 30 30 #include "yat/random/random.h" -
trunk/yat/utility/VectorConstView.cc
r1029 r1121 26 26 27 27 #include "VectorConstView.h" 28 #include " matrix.h"28 #include "Matrix.h" 29 29 30 30 namespace theplu { … … 56 56 57 57 58 VectorConstView::VectorConstView(const matrix& m, size_t i, bool row)58 VectorConstView::VectorConstView(const Matrix& m, size_t i, bool row) 59 59 : VectorBase(), const_view_(NULL) 60 60 { -
trunk/yat/utility/VectorConstView.h
r1029 r1121 38 38 namespace utility { 39 39 40 class matrix;40 class Matrix; 41 41 42 42 /** … … 100 100 use is undefined. 101 101 */ 102 VectorConstView(const matrix& m, size_t i, bool row=true);102 VectorConstView(const Matrix& m, size_t i, bool row=true); 103 103 104 104 /** -
trunk/yat/utility/VectorMutable.cc
r1118 r1121 26 26 27 27 #include "VectorMutable.h" 28 #include "matrix.h"29 28 #include "utility.h" 30 29 #include "yat/random/random.h" -
trunk/yat/utility/VectorView.cc
r1118 r1121 27 27 #include "VectorView.h" 28 28 #include "VectorMutable.h" 29 #include " matrix.h"29 #include "Matrix.h" 30 30 #include "utility.h" 31 31 #include "yat/random/random.h" … … 77 77 78 78 79 VectorView::VectorView( matrix& m, size_t i, bool row)79 VectorView::VectorView(Matrix& m, size_t i, bool row) 80 80 : VectorMutable() 81 81 { -
trunk/yat/utility/VectorView.h
r1120 r1121 43 43 namespace utility { 44 44 45 class matrix;45 class Matrix; 46 46 class Vector; 47 47 … … 144 144 /// use is undefined. 145 145 /// 146 VectorView( matrix& m, size_t i, bool row=true);146 VectorView(Matrix& m, size_t i, bool row=true); 147 147 148 148 /** -
trunk/yat/utility/WeNNI.cc
r1000 r1121 25 25 26 26 #include "WeNNI.h" 27 #include " matrix.h"27 #include "Matrix.h" 28 28 #include "stl_utility.h" 29 29 … … 37 37 38 38 39 WeNNI::WeNNI(const utility:: matrix& matrix,const utility::matrix& flag,39 WeNNI::WeNNI(const utility::Matrix& matrix,const utility::Matrix& flag, 40 40 const u_int neighbours) 41 41 : NNI(matrix,flag,neighbours), imputed_data_raw_(matrix) -
trunk/yat/utility/WeNNI.h
r1000 r1121 29 29 30 30 #include "NNI.h" 31 #include " matrix.h"31 #include "Matrix.h" 32 32 33 33 #include <iostream> … … 54 54 /// Constructor 55 55 /// 56 WeNNI(const utility:: matrix& matrix,const utility::matrix& weight,56 WeNNI(const utility::Matrix& matrix,const utility::Matrix& weight, 57 57 const u_int neighbours); 58 58 … … 67 67 /// @return A const reference to imputed_data_raw. 68 68 /// 69 const utility:: matrix& imputed_data_raw(void) const69 const utility::Matrix& imputed_data_raw(void) const 70 70 { return imputed_data_raw_; } 71 71 … … 73 73 private: 74 74 75 utility:: matrix imputed_data_raw_;75 utility::Matrix imputed_data_raw_; 76 76 }; 77 77 -
trunk/yat/utility/kNNI.cc
r1000 r1121 36 36 namespace utility { 37 37 38 kNNI::kNNI(const utility:: matrix& matrix,const utility::matrix& flag,38 kNNI::kNNI(const utility::Matrix& matrix,const utility::Matrix& flag, 39 39 const u_int neighbours) 40 40 : NNI(matrix,flag,neighbours) -
trunk/yat/utility/kNNI.h
r1000 r1121 55 55 /// Constructor 56 56 /// 57 kNNI(const utility:: matrix& matrix,const utility::matrix& weight,57 kNNI(const utility::Matrix& matrix,const utility::Matrix& weight, 58 58 const u_int neighbours); 59 59
Note: See TracChangeset
for help on using the changeset viewer.