Advertisement
Guest User

float64* SGMatrix<float64>::pinv()

a guest
Jun 20th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include<shogun/mathematics/eigen3.h>
  2.  
  3. #include<shogun/base/init.h>
  4. #include<shogun/lib/SGMatrix.h>
  5. #include<shogun/lib/SGVector.h>
  6. #include<shogun/features/DenseFeatures.h>
  7.  
  8. #include<shogun/labels/BinaryLabels.h>
  9. #include<shogun/io/SGIO.h>
  10. #include<shogun/mathematics/Math.h>
  11.  
  12. #include<iostream>
  13.  
  14. using namespace std;
  15. using namespace shogun;
  16. using namespace Eigen;
  17.  
  18. int main()
  19. {
  20.     init_shogun_with_defaults();
  21.  
  22.     SGMatrix<float64_t> test_matrix = SGMatrix<float64_t>(3,3);
  23.     for (int i=0; i<3; i++)
  24.         for (int j=0; j<3; j++)
  25.             test_matrix(i,j)= i*j+j+i+1;
  26.  
  27.    
  28.    
  29.    
  30.     test_matrix.display_matrix();
  31.  
  32.     //
  33.     // test_matrix...
  34.     //
  35.     //     1     2     3
  36.     //     2     4     6
  37.     //     3     6     9
  38.     //
  39.  
  40.    float64_t* ans;
  41.  
  42.    
  43.    ans = SGMatrix<float64_t>::pinv(test_matrix.matrix, test_matrix.num_rows, test_matrix.num_cols, NULL);
  44.  
  45.     cout<<"----------------------"<<endl;
  46.  
  47.    for(int i=0; i<9; i++)
  48.        cout<<ans[i]<<endl;
  49. //
  50. //
  51. //  output.
  52. //
  53. //  -1.00205e+15
  54. //  -2.50513e+14
  55. //  5.01026e+14
  56. //  3.07778e+18
  57. //  -4.4187e+18
  58. //  1.91987e+18
  59. //  -2.05152e+18
  60. //  2.94588e+18
  61. //  -1.28008e+18
  62. //
  63. //
  64. //
  65. //
  66. //
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement