Last change
on this file since 25 was
25,
checked in by Peter, 19 years ago
|
to calculate Kernel Matrix
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
647 bytes
|
Line | |
---|
1 | // $Id: Kernel.cc 25 2003-08-06 17:38:17Z peter $ |
---|
2 | |
---|
3 | // System |
---|
4 | #include <math.h> |
---|
5 | |
---|
6 | |
---|
7 | // Thep C++ Tools |
---|
8 | #include "Kernel.h" |
---|
9 | #include "KernelFunction.h" |
---|
10 | #include "matrix.h" |
---|
11 | #include "vector.h" |
---|
12 | |
---|
13 | using namespace thep_cpp_tools; |
---|
14 | |
---|
15 | Kernel::Kernel(const thep_gsl_api::matrix& data, const KernelFunction& kf) |
---|
16 | { |
---|
17 | k_=thep_gsl_api::matrix(data.cols(),data.cols(),0); |
---|
18 | for(u_int i=0;i<data.cols();i++) |
---|
19 | for(u_int j=0;j<i+1;j++) { |
---|
20 | double tmp = kf(data.col_vector(i),data.col_vector(j)); |
---|
21 | k_.set(i,j,tmp); |
---|
22 | } |
---|
23 | |
---|
24 | // Copy lower triangle to upper triangle of Kernel matrix |
---|
25 | for(u_int i=0;i<data.cols()-1;i++) |
---|
26 | for(u_int j=i+1;j<data.cols();j++) |
---|
27 | k_.set(i,j,k_.get(j,i)); |
---|
28 | } |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
Note: See
TracBrowser
for help on using the repository browser.