Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<shogun/mathematics/eigen3.h>
- #include<shogun/base/init.h>
- #include<shogun/lib/SGMatrix.h>
- #include<shogun/lib/SGVector.h>
- #include<shogun/features/DenseFeatures.h>
- #include<shogun/labels/BinaryLabels.h>
- #include<shogun/io/SGIO.h>
- #include<shogun/mathematics/Math.h>
- #include<iostream>
- using namespace std;
- using namespace shogun;
- using namespace Eigen;
- int main()
- {
- init_shogun_with_defaults();
- SGMatrix<float64_t> test_matrix = SGMatrix<float64_t>(3,3);
- for (int i=0; i<3; i++)
- for (int j=0; j<3; j++)
- test_matrix(i,j)= i*j+j+i+1;
- test_matrix.display_matrix();
- //
- // test_matrix...
- //
- // 1 2 3
- // 2 4 6
- // 3 6 9
- //
- float64_t* ans;
- ans = SGMatrix<float64_t>::pinv(test_matrix.matrix, test_matrix.num_rows, test_matrix.num_cols, NULL);
- cout<<"----------------------"<<endl;
- for(int i=0; i<9; i++)
- cout<<ans[i]<<endl;
- //
- //
- // output.
- //
- // -1.00205e+15
- // -2.50513e+14
- // 5.01026e+14
- // 3.07778e+18
- // -4.4187e+18
- // 1.91987e+18
- // -2.05152e+18
- // 2.94588e+18
- // -1.28008e+18
- //
- //
- //
- //
- //
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement