资源简介
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
相关资源
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- 基于mfc的多线程文件传输
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 利用C++哈希表的方法实现电话号码查
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 移木块游戏,可以自编自玩,vc6.0编写
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- C++纯文字DOS超小RPG游戏
- 个人日常财务管理系统(C语言)
- MFC数字钟(基于VC6.0)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- 安科瑞智能电能表MODBUS通讯程序 VC6
评论
共有 条评论