资源简介
C语言写的矩阵库,适合做矩阵运算的程序调用
代码片段和文件信息
/**************************************************************************
**
** Copyright (C) 1993 David E. Steward & Zbigniew Leyk all rights reserved.
**
** Meschach Library
**
** This Meschach Library is provided “as is“ without any express
** or implied warranty of any kind with respect to this software.
** In particular the authors shall not be liable for any direct
** indirect special incidental or consequential damages arising
** in any way from use of the software.
**
** Everyone is granted permission to copy modify and redistribute this
** Meschach Library provided:
** 1. All copies contain this copyright notice.
** 2. All modified copies shall carry a notice stating who
** made the last modification and the date of such modification.
** 3. No charge is made for this software or works derived from it.
** This clause shall not be construed as constraining other software
** distributed on the same medium as this software nor is a
** distribution fee considered a charge.
**
***************************************************************************/
/*
Arnoldi method for finding eigenvalues of large non-symmetric
matrices
*/
#include
#include
#include “matrix.h“
#include “matrix2.h“
#include “sparse.h“
static char rcsid[] = “$Id: arnoldi.cv 1.3 1994/01/13 05:45:40 des Exp $“;
/* arnoldi -- an implementation of the Arnoldi method */
MAT *arnoldi(AA_paramx0mh_remQH)
VEC *(*A)();
void *A_param;
VEC *x0;
int m;
Real *h_rem;
MAT *Q *H;
{
STATIC VEC *v=VNULL *u=VNULL *r=VNULL *s=VNULL *tmp=VNULL;
int i;
Real h_val;
if ( ! A || ! Q || ! x0 )
error(E_NULL“arnoldi“);
if ( m <= 0 )
error(E_BOUNDS“arnoldi“);
if ( Q->n != x0->dim || Q->m != m )
error(E_SIZES“arnoldi“);
m_zero(Q);
H = m_resize(Hmm);
m_zero(H);
u = v_resize(ux0->dim);
v = v_resize(vx0->dim);
r = v_resize(rm);
s = v_resize(sm);
tmp = v_resize(tmpx0->dim);
MEM_STAT_REG(uTYPE_VEC);
MEM_STAT_REG(vTYPE_VEC);
MEM_STAT_REG(rTYPE_VEC);
MEM_STAT_REG(sTYPE_VEC);
MEM_STAT_REG(tmpTYPE_VEC);
sv_mlt(1.0/v_norm2(x0)x0v);
for ( i = 0; i < m; i++ )
{
set_row(Qiv);
u = (*A)(A_paramvu);
r = mv_mlt(Qur);
tmp = vm_mlt(Qrtmp);
v_sub(utmpu);
h_val = v_norm2(u);
/* if u == 0 then we have an exact subspace */
if ( h_val == 0.0 )
{
*h_rem = h_val;
return H;
}
/* iterative refinement -- ensures near orthogonality */
do {
s = mv_mlt(Qus);
tmp = vm_mlt(Qstmp);
v_sub(utmpu);
v_add(rsr);
} while ( v_norm2(s) > 0.1*(h_val = v_norm2(u)) );
/* now that u is nearly orthogonal to Q update H */
set_col(Hir);
if ( i == m-1 )
{
*h_rem = h_val;
continue;
}
/* H->me[i+1][i] = h_val; */
m_set_val(Hi+1ih_val);
sv_mlt(1.0/h_valuv);
}
#ifde
相关资源
- BezierCurve 贝塞尔曲线计算 c++源码
- 飞机订票系统,c++程序
- C++程序设计语言特别版源码
- C++实现播放GIF图片
- C++编写一个计算器,实现加减乘除,
- AES128 C语言实现源码及应用例程
- c语言实现 FCFS和SJF调度算法
- 基于C++的内存池的实现
- 马踏棋盘C语言源代码
- 快速傅立叶变换(FFT) C,C#源码
- 二叉树已知后序和中序遍历求前序遍
- 动态添加、删除树形控件的节点,获
- mfc+opengl离散点绘制曲面
- C语言编写简单聊天室
- activemq-cpp开发手册.pdf
- 简易计算器基于对话框VC6.0
- rs485通讯C++
- erf()函数C语言代码
- C++知识体系图解超详细
- C语言课程设计报告-长整数四则运算
- 数据结构课程设计 通讯录的制作
- C++课件+STL
- STC15的modbus程序
- 作业调度算法c语言版
- MFC 实现读取文件中的数字,并求和
- C++哈夫曼编码与译码课程设计实现源
- C++ builder 网络传输程序含服务器和客
- 数据结构课程设计——族谱管理系统
- C++矩阵的关系判断
- tftp_vs2010.rar
评论
共有 条评论