StdAfx.cpp
资源名称:DLT.rar [点击查看]
上传用户:szacenet
上传日期:2022-06-20
资源大小:317k
文件大小:1k
源码类别:
图形图象
开发平台:
Visual C++
- // stdafx.cpp : source file that includes just the standard includes
- // DLT.pch will be the pre-compiled header
- // stdafx.obj will contain the pre-compiled type information
- #include "stdafx.h"
- //矩阵转置
- void transpose(double *m1,double *m2,int m,int n)
- { int i,j;
- for(i=0;i<m;i++)
- for(j=0;j<n;j++)
- m2[j*m+i]=m1[i*n+j];
- return;
- }
- /*正定矩阵求逆*/
- void inv(double *a,int n)
- {
- int i,j,k;
- for(k=0;k<n;k++)
- {
- for(i=0;i<n;i++)
- {
- if(i!=k)
- *(a+i*n+k)=-*(a+i*n+k)/(*(a+k*n+k));
- }
- *(a+k*n+k)=1/(*(a+k*n+k));
- for(i=0;i<n;i++)
- {
- if(i!=k)
- {
- for(j=0;j<n;j++)
- {
- if(j!=k)
- *(a+i*n+j)+=*(a+k*n+j)* *(a+i*n+k);
- }
- }
- }
- for(j=0;j<n;j++)
- {
- if(j!=k)
- *(a+k*n+j)*=*(a+k*n+k);
- }
- }
- }
- //矩阵相乘
- void mult(double *m1,double *m2,double *result,int i_1,int j_12,int j_2)
- {
- int i,j,k;
- for(i=0;i<i_1;i++)
- for(j=0;j<j_2;j++)
- {
- result[i*j_2+j]=0.0;
- for(k=0;k<j_12;k++)
- result[i*j_2+j]+=m1[i*j_12+k]*m2[j+k*j_2];
- }
- return;
- }
English
