#include <iostream>#include <algorithm>#include <string>#include <io.h>#include "highgui.h"#include "cv.h"#pragma comment(lib, "cxcore.lib")using namespace std; inline void cvDoubleMatPrint( const CvMat* mat );void SVD(double *SA, double *SU, double *SS, double *SV);int main(){ double A[16]={1,1,1,1,0,1,0,0,0,0,1,1,0,0,0,0}, U[16], S[16], V[16]; SVD(A, U, S, V);printf("V:============\n");for(int j=0,i=0;i<16;i++){cout<<V[i]<<',';j++;if(j%4==0) cout<<endl;}return 0;} void SVD(double *SA, double *SU, double *SS, double *SV) { CvMat A, U, S, V; cvInitMatHeader(&A,4,4,CV_64FC1,SA,CV_AUTOSTEP); cvInitMatHeader(&U,4,4,CV_64FC1,SU,CV_AUTOSTEP); cvInitMatHeader(&S,4,4,CV_64FC1,SS,CV_AUTOSTEP); cvInitMatHeader(&V,4,4,CV_64FC1,SV,CV_AUTOSTEP); cvSVD(&A, &U, &S, &V, CV_SVD_U_T); printf("A:============\n"); cvDoubleMatPrint( &A); printf("U:============\n"); cvDoubleMatPrint( &U); printf("S:============\n"); cvDoubleMatPrint( &S); printf("V:============\n"); cvDoubleMatPrint( &V); }/* 个别小知识介绍:对A进行SVD分解后,矩阵V的最后一列其实是齐次方程Ax=0的一组解//输出:A:============1.000000 1.000000 1.000000 1.0000000.000000 1.000000 0.000000 0.0000000.000000 0.000000 1.000000 1.0000000.000000 0.000000 0.000000 0.000000U:============2.324366 0.000000 0.000000 0.0000000.000000 1.147184 0.000000 0.0000000.000000 0.000000 0.530368 0.0000000.000000 0.000000 0.000000 0.000000S:============-0.846041 -0.192165 -0.497279 0.000000-0.226091 -0.715409 0.661115 0.000000-0.482801 0.671761 0.561818 0.0000000.000000 0.000000 0.000000 1.000000V:============-0.363988 -0.197084 -0.910314 0.000000-0.446662 -0.820705 0.356281 0.000000-0.577930 0.379210 0.148985 0.707107-0.577930 0.379210 0.148985 -0.707107V:============-0.363988,-0.197084,-0.910314,0,-0.446662,-0.820705,0.356281,0,-0.57793,0.37921,0.148985,0.707107,-0.57793,0.37921,0.148985,-0.707107,Press any key to continue//matlab:A = 1 1 1 1 0 1 0 0 0 0 1 1 0 0 0 0>> [S V D]=svd(A)S = 0.8460 0.2261 0.4828 0 0.1922 0.7154 -0.6718 0 0.4973 -0.6611 -0.5618 0 0 0 0 1.0000V = 2.3244 0 0 0 0 1.1472 0 0 0 0 0.5304 0 0 0 0 0D = 0.3640 0.1971 0.9103 0 0.4467 0.8207 -0.3563 0 0.5779 -0.3792 -0.1490 -0.7071 0.5779 -0.3792 -0.1490 0.7071*/ inline void cvDoubleMatPrint( const CvMat* mat ){ int i, j; for( i = 0; i < mat->rows; i++ ) { for( j = 0; j < mat->cols; j++ ) { printf( "%lf ",cvmGet( mat, i, j ) ); } printf( "\n" ); }}
- cvSVD(&A, &U, &S, &V, CV_SVD_U_T);
- 矩阵转置 [u,s,v]=svd(a)
- cvsvd
- python_SVD_matlab版svd(U*S*V^T) & python版numpy.linalg.svd(U*S*V)
- N o v e m b e r 6 t h T u e s d a y
- N o v e m b e r 8 t h T h u r s d a y
- N o v e m b e r 1 3 t h T u e s d a y
- N o v e m b e r 2 0 t h T u e s d a y
- N o v e m b e r 2 7 t h T u e s d a y
- N o v e m b e r 2 9 t h T h u r s d a y
- java泛型中的E,K,V,T,U,S
- Visual Studio 2012上使用共享配置项propertysheet
- "Algorithms" by S. D., C.H. P., and U.V. V., recommended
- The value for the useBean class attribute is invalied
- Windows环境下Oracle VM VirtualBox安装ubuntu
- PHP正则表达式 /i, /s, /x,/u, /U, /A, /D, /S等模式修饰符
- PHP正则表达式 /i, /s, /x,/u, /U, /A, /D, /S等模式修饰符
- PHP正则表达式 /i, /s, /x,/u, /U, /A, /D, /S等模式修饰符
- INF SourceDisksNames Section 和 SourceDisksFiles Section详解
- Linux 学习笔记
- 348 - Optimal Array Multiplication Sequence
- http发送get请求的总结
- ScrollView或者ListView中嵌套ViewPager,展示不出来问题。
- cvSVD(&A, &U, &S, &V, CV_SVD_U_T);
- 分享一个java写的简单计算器
- SSH 配置
- 把某某XX文件夹的下得文件拷贝到任意磁盘目录下
- linux下字符串和整型互转
- VMware 安装 ubuntu
- Eclipse java swing开发环境
- Fedora 常用软件安装
- 四维空间---概念