/**************************************************************************
**
** 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.
**
***************************************************************************/
MESCHACH VERSION 1.2A
---------------------
TUTORIAL
========
In this manual the basic data structures are introduced, and some of the
more basic operations are illustrated. Then some examples of how to use
the data structures and procedures to solve some simple problems are given.
The first example program is a simple 4th order Runge-Kutta solver for
ordinary differential equations. The second is a general least squares
equation solver for over-determined equations. The third example
illustrates how to solve a problem involving sparse matrices. These
examples illustrate the use of matrices, matrix factorisations and solving
systems of linear equations. The examples described in this manual are
implemented in tutorial.c.
While the description of each aspect of the system is brief and far from
comprehensive, the aim is to show the different aspects of how to set up
programs and routines and how these work in practice, which includes I/O
and error-handling issues.
1. THE DATA STRUCTURES AND SOME BASIC OPERATIONS
The three main data structures are those describing vectors, matrices
and permutations. These have been used to create data structures for
simplex tableaus for linear programming, and used with data structures for
sparse matrices etc. To use the system reliably, you should always use
pointers to these data structures and use library routines to do all the
necessary initialisation.
In fact, for the operations that involve memory management (creation,
destruction and resizing), it is essential that you use the routines
provided.
For example, to create a matrix A of size 34 , a vector x of dimension
10, and a permutation p of size 10, use the following code:
#include "matrix.h"
..............
main()
{
MAT *A;
VEC *x;
PERM *p;
..........
A = m_get(3,4);
x = v_get(10);
p = px_get(10);
..........
}
This initialises these data structures to have the given size. The
matrix A and the vector x are initially all zero, while p is initially the
identity permutation.
They can be disposed of by calling M_FREE(A), V_FREE(x) and PX_FREE(p)
respectively if you need to re-use the memory for something else. The
elements of each data structure can be accessed directly using the members
(or fields) of the corresponding structures. For example the (i,j)
component of A is accessed by A->me[i][j], x_i by x->ve[i] and p_i by
p->pe[i].
Their sizes are also directly accessible: A->m and A->n are the number
of rows and columns of A respectively, x->dim is the dimension of x , and
size of p is p->size.
Note that the indexes are zero relative just as they are in ordinary C,
so that the index i in x->ve[i] can range from 0 to x->dim -1 . Thus the
total number of entries of a vector is exactly x->dim.
While this alone is sufficient to allow a programmer to do any desired
operation with vectors and matrices it is neither convenient for the
programmer, nor efficient use of the CPU. A whole library has been
implemented to reduce the burden on the programmer in implementing
algorithms with vectors and matrices. For instance, to copy a vector from
x to y it is sufficient to write y = v_copy(x,VNULL). The VNULL is the
NULL vector, and usually tells the routine called to create a vector for
output.
Thus, the v_copy function will create a vector which has the same size
as x and all the components are equal to those of x. If y has already
been created then you can write y = v_copy(x,y); in general, writing
``v_copy(x,y);'' is not enough! If y is NULL, then it is created (to have
the correct size, i.e. the same size as x), and if it is the wrong size,
then it is resized to have the correct size (i.e. same size as x). Note
that for all the following functions, the output value is returned, even if
you have a non-NULL value as the output argument. This is the standard
across the entire library.
Addition, subtraction and scalar multiples of vectors can be computed by
calls to library routines: v_add(x,y,out), v_sub(x,y,out), sv_mlt(s,x,out)
where x and y are input vectors (with data type VEC *), out is the output
vector (same data type) and s is a double precision number (data type
double). There is also a special combination routine, which computes
out=v_1+s,v_2 in a single routine: v_mltadd(v1,v2,s,out). This is not only
extremely useful, it is also more efficient than using the scalar-vector
multiply and vector addition routines separately.
Inner products can be computed directly: in_prod(x,y) returns the inner
product of x and y. Note that extended precision evaluation is not
guaranteed. The standard installation options uses double precision
operations throughout the library.
Equivalent operations can be performed on matrices: m_add(A,B,C) which
returns C=A+B , and sm_mlt(s,A,C) which returns C=sA . The data types of
A, B and C are all MAT *, while that of s is type double as before. The
matrix NULL is called MNULL.
Multiplying matrices and vectors can be done by a single function call:
mv_mlt(A,x,out) returns out=A*x while vm_mlt(A,x,out) returns out=A^T*x , or
equivalently, out^T=x^T*A . Note that there is no distinction between row
and column vectors unlike certain interactive environments such as MATLAB
or MATCALC.
Permutations are also an essential part of the package. Vectors can be
permuted by using px_vec(p,x,p_x), rows and columns of matrices can be
permuted by using px_rows(p,A,p_A), px_cols(p,A,A_p), and permutations can
be multiplied using px_mlt(p1,p2,p1_p2) and inverted using px_inv(p,p_inv).
The NULL permutation is called PXNULL.
There are also utility routines to initialise or re-initialise these
data structures: v_zero(x), m_zero(A), m_ident(A) (which sets A=I of the
correct size), v_rand(x), m_rand(A) which sets the entries of x and A
respectively to be randomly and uniformly selected between zero and one,
and px_ident(p) which sets p to be an identity permutation.
Input and output are accomplished by library routines v_input(x),
m_input(A), and px_input(p). If a null object is passed to any of these
input routines, all data will be obtained from the input file, which is
stdin. If input is taken from a keyboard then the user will be prompted
for all the data items needed; if input is taken from a file, then the
input will have to be of the same format as that produced by the output
routines, which are: v_output(x), m_output(A) and px_output(p). This
output is both human and machine readable!
If you wish to send the data to a file other than the standard output
device stdout, or receive input from a file or device other than the
standard input device stdin, take the appropriate routine above, use the
``foutpout'' suffix instead of just ``output'', and add a file pointer as
the
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计&课设-GetFEM存储库镜像.zip
共1702个文件
cc:211个
h:192个
rst:163个
需积分: 1 0 下载量 149 浏览量
2024-01-08
22:30:44
上传
评论
收藏 24.69MB ZIP 举报
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计&课设-GetFEM存储库镜像.zip (1702个子文件)
patch.1 2KB
patch.2 687B
patch.3 298B
configure.ac 48KB
Makefile.am 17KB
Makefile.am 10KB
Makefile.am 10KB
Makefile.am 8KB
Makefile.am 5KB
Makefile.am 4KB
Makefile.am 4KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 990B
Makefile.am 113B
ansys2getfem_mesh 7KB
AUTHORS 685B
biblio.bib 290B
gfm_common.c 46KB
spbkp.c 35KB
iternsym.c 30KB
getfem_python.c 29KB
sparse.c 23KB
memory.c 19KB
schur.c 18KB
sprow.c 17KB
spchfctr.c 15KB
zmemory.c 15KB
zmatop.c 15KB
bdfactor.c 14KB
gfm_common.c 14KB
gfm_common.c 14KB
itersym.c 14KB
zqrfctr.c 13KB
gfi_array.c 13KB
vecop.c 13KB
matrixio.c 13KB
qrfactor.c 13KB
matop.c 12KB
zvecop.c 11KB
zschur.c 11KB
extras.c 11KB
splufctr.c 11KB
zmatio.c 10KB
err.c 10KB
svd.c 10KB
ivecop.c 10KB
mfunc.c 9KB
meminfo.c 9KB
gfm_rpc_mexint.c 9KB
gfm_rpc_mexint.c 9KB
iter0.c 9KB
memstat.c 8KB
bkpfacto.c 8KB
sparseio.c 8KB
sci_cgs.c 8KB
zsolve.c 7KB
sci_cgne.c 7KB
pxop.c 7KB
spswap.c 7KB
sci_gmres.c 7KB
sci_mgcr.c 7KB
zlufctr.c 7KB
lufactor.c 7KB
solve.c 7KB
gfi_rpc_svc.c 6KB
machine.c 6KB
symmeig.c 6KB
init.c 6KB
zmatlab.c 6KB
sci_splu.c 6KB
gfi_rpc_xdr.c 5KB
copy.c 5KB
zhsehldr.c 5KB
sci_spluinc.c 5KB
zcopy.c 5KB
共 1702 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
资源评论
白话机器学习
- 粉丝: 9792
- 资源: 7681
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功