Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1004 B

  1. // svd.cpp : Defines the entry point for the console application.
  2. //
  3. #include "svd.h"
  4. namespace SVD
  5. {
  6. void Test()
  7. {
  8. SvdIterator<float> test;
  9. for ( int nTest = 0; nTest< 100; ++nTest )
  10. {
  11. Matrix3<float> a;
  12. for ( int i = 0; i < 3; ++i )
  13. for ( int j = 0; j < 3; ++j )
  14. a.m[ i ][ j ] = i * 3 + j;//float( rand() ) / RAND_MAX - 0.5f;
  15. test.Init( a );
  16. Msg( "%d", nTest );
  17. for ( int i = 0; i < 5; ++i )
  18. {
  19. Matrix3< float > v = test.ComputeV();
  20. // B = US = AV
  21. Matrix3< float > us = a * v;
  22. //float flOrtho = OrthogonalityError( us );
  23. Matrix3< float > reconstruction = MulT( us, v );
  24. //float flRec = ( reconstruction - a ).FrobeniusNorm();
  25. SymMatrix3< float > ata = AtA( a );
  26. float flOffDiagError = ata.OffDiagNorm() / ata.DiagNorm();
  27. // Msg( "\t%g", logf( flRec ) / logf( 10 ) );
  28. // Msg( "\t%g", logf( flOrtho ) / logf( 10 ) );
  29. Msg( "\t%g", logf( flOffDiagError ) / logf( 10 ) );
  30. test.Iterate( 1 );
  31. }
  32. Msg( "\n" );
  33. }
  34. }
  35. }