Changeset 26551
- Timestamp:
- Jan 8, 2010, 4:45:02 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/psLib/src/math
- Files:
-
- 2 edited
-
psMatrix.c (modified) (3 diffs)
-
psMatrix.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psLib/src/math/psMatrix.c
r26372 r26551 1033 1033 } 1034 1034 1035 psVector *psMatrixSolveSVD(psVector *out, const psImage *matrix, const psVector *vector )1035 psVector *psMatrixSolveSVD(psVector *out, const psImage *matrix, const psVector *vector, float thresh) 1036 1036 { 1037 1037 #define psMatrixSolveSVD_EXIT {psFree(out); return NULL; } … … 1063 1063 gsl_vector_free(work); 1064 1064 1065 if (isfinite(thresh) && thresh > 0.0) { 1066 // Trim the singular values 1067 thresh *= gsl_vector_get(S, 0); 1068 psTrace("psLib.math", 8, "Singular value 0: %lf", gsl_vector_get(S, 0)); 1069 for (int i = 1; i < numCols; i++) { 1070 double value = gsl_vector_get(S, i); // Singular value 1071 if (value < thresh) { 1072 psTrace("psLib.math", 5, "Trimming singular value %d: %lf", i, value); 1073 gsl_vector_set(S, i, 0.0); 1074 for (int j = 0; j < numCols; j++) { 1075 // Being thorough; probably unnecessary 1076 gsl_matrix_set(V, j, i, 0.0); 1077 gsl_matrix_set(A, j, i, 0.0); 1078 } 1079 } else { 1080 psTrace("psLib.math", 5, "Singular value %d: %lf", i, value); 1081 } 1082 } 1083 } 1084 1065 1085 // Solve system (or minimise least-squares if overconstrained): Ax = b 1066 1086 gsl_vector *b = gsl_vector_alloc(numCols); // Vector b … … 1196 1216 return true; 1197 1217 } 1218 -
branches/eam_branches/20091201/psLib/src/math/psMatrix.h
r26372 r26551 192 192 psVector *solution, ///< Solution to output, or NULL 193 193 const psImage *matrix, ///< Matrix to be solved 194 const psVector *vector ///< Vector of values 194 const psVector *vector, ///< Vector of values 195 float thresh ///< Threshold relative to maximum for trimming singular values 195 196 ); 196 197 197 198 198 /// Single value decomposition (original by Andy Becker, updated by EAM)
Note:
See TracChangeset
for help on using the changeset viewer.
