/********************************************************************
AP Library version 1.2
Copyright (c) 2003-2007, Sergey Bochkanov (ALGLIB project).
See www.alglib.net or alglib.sources.ru for details.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer listed
in this license in the documentation and/or other materials
provided with the distribution.
- Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************/
#include "stdafx.h"
#include "ap.h"
/********************************************************************
Optimized ABLAS interface
********************************************************************/
#ifdef AP_WIN32
#include <windows.h>
extern "C"
{
typedef double (*_ddot1)(const double*, const double*, long);
typedef void (*_dmove1)(const double*, const double*, long);
typedef void (*_dmoves1)(const double*, const double*, long, double);
typedef void (*_dmoveneg1)(const double*, const double*, long);
typedef void (*_dadd1)(const double*, const double*, long);
typedef void (*_dadds1)(const double*, const double*, long, double);
typedef void (*_dsub1)(const double*, const double*, long);
typedef void (*_dmuls1)(const double*, long, double);
}
HINSTANCE ABLAS = LoadLibrary("ablas.dll");
static _ddot1 ddot1 = ABLAS==NULL ? NULL : (_ddot1) GetProcAddress(ABLAS, "ASMDotProduct1");
static _dmove1 dmove1 = ABLAS==NULL ? NULL : (_dmove1) GetProcAddress(ABLAS, "ASMMove1");
static _dmoves1 dmoves1 = ABLAS==NULL ? NULL : (_dmoves1) GetProcAddress(ABLAS, "ASMMoveS1");
static _dmoveneg1 dmoveneg1 = ABLAS==NULL ? NULL : (_dmoveneg1) GetProcAddress(ABLAS, "ASMMoveNeg1");
static _dadd1 dadd1 = ABLAS==NULL ? NULL : (_dadd1) GetProcAddress(ABLAS, "ASMAdd1");
static _dadds1 dadds1 = ABLAS==NULL ? NULL : (_dadds1) GetProcAddress(ABLAS, "ASMAddS1");
static _dsub1 dsub1 = ABLAS==NULL ? NULL : (_dsub1) GetProcAddress(ABLAS, "ASMSub1");
static _dmuls1 dmuls1 = ABLAS==NULL ? NULL : (_dmuls1) GetProcAddress(ABLAS, "ASMMulS1");
#endif
const double ap::machineepsilon = 5E-16;
const double ap::maxrealnumber = 1E300;
const double ap::minrealnumber = 1E-300;
/********************************************************************
ap::complex operations
********************************************************************/
const bool ap::operator==(const ap::complex& lhs, const ap::complex& rhs)
{ return lhs.x==rhs.x && lhs.y==rhs.y; }
const bool ap::operator!=(const ap::complex& lhs, const ap::complex& rhs)
{ return lhs.x!=rhs.x || lhs.y!=rhs.y; }
const ap::complex ap::operator+(const ap::complex& lhs)
{ return lhs; }
const ap::complex ap::operator-(const ap::complex& lhs)
{ return ap::complex(-lhs.x, -lhs.y); }
const ap::complex ap::operator+(const ap::complex& lhs, const ap::complex& rhs)
{ ap::complex r = lhs; r += rhs; return r; }
const ap::complex ap::operator+(const ap::complex& lhs, const double& rhs)
{ ap::complex r = lhs; r += rhs; return r; }
const ap::complex ap::operator+(const double& lhs, const ap::complex& rhs)
{ ap::complex r = rhs; r += lhs; return r; }
const ap::complex ap::operator-(const ap::complex& lhs, const ap::complex& rhs)
{ ap::complex r = lhs; r -= rhs; return r; }
const ap::complex ap::operator-(const ap::complex& lhs, const double& rhs)
{ ap::complex r = lhs; r -= rhs; return r; }
const ap::complex ap::operator-(const double& lhs, const ap::complex& rhs)
{ ap::complex r = lhs; r -= rhs; return r; }
const ap::complex ap::operator*(const ap::complex& lhs, const ap::complex& rhs)
{ return ap::complex(lhs.x*rhs.x - lhs.y*rhs.y, lhs.x*rhs.y + lhs.y*rhs.x); }
const ap::complex ap::operator*(const ap::complex& lhs, const double& rhs)
{ return ap::complex(lhs.x*rhs, lhs.y*rhs); }
const ap::complex ap::operator*(const double& lhs, const ap::complex& rhs)
{ return ap::complex(lhs*rhs.x, lhs*rhs.y); }
const ap::complex ap::operator/(const ap::complex& lhs, const ap::complex& rhs)
{
ap::complex result;
double e;
double f;
if( fabs(rhs.y)<fabs(rhs.x) )
{
e = rhs.y/rhs.x;
f = rhs.x+rhs.y*e;
result.x = (lhs.x+lhs.y*e)/f;
result.y = (lhs.y-lhs.x*e)/f;
}
else
{
e = rhs.x/rhs.y;
f = rhs.y+rhs.x*e;
result.x = (lhs.y+lhs.x*e)/f;
result.y = (-lhs.x+lhs.y*e)/f;
}
return result;
}
const ap::complex ap::operator/(const double& lhs, const ap::complex& rhs)
{
ap::complex result;
double e;
double f;
if( fabs(rhs.y)<fabs(rhs.x) )
{
e = rhs.y/rhs.x;
f = rhs.x+rhs.y*e;
result.x = lhs/f;
result.y = -lhs*e/f;
}
else
{
e = rhs.x/rhs.y;
f = rhs.y+rhs.x*e;
result.x = lhs*e/f;
result.y = -lhs/f;
}
return result;
}
const ap::complex ap::operator/(const ap::complex& lhs, const double& rhs)
{ return ap::complex(lhs.x/rhs, lhs.y/rhs); }
const double ap::abscomplex(const ap::complex &z)
{
double w;
double xabs;
double yabs;
double v;
xabs = fabs(z.x);
yabs = fabs(z.y);
w = xabs>yabs ? xabs : yabs;
v = xabs<yabs ? xabs : yabs;
if( v==0 )
return w;
else
{
double t = v/w;
return w*sqrt(1+t*t);
}
}
const ap::complex ap::conj(const ap::complex &z)
{ return ap::complex(z.x, -z.y); }
const ap::complex ap::csqr(const ap::complex &z)
{ return ap::complex(z.x*z.x-z.y*z.y, 2*z.x*z.y); }
/********************************************************************
BLAS functions
********************************************************************/
double ap::vdotproduct(const double *v1, const double *v2, int N)
{
#ifdef AP_WIN32
if( ddot1!=NULL )
return ddot1(v1, v2, N);
#endif
return ap::_vdotproduct<double>(v1, v2, N);
}
ap::complex ap::vdotproduct(const ap::complex *v1, const ap::complex *v2, int N)
{
return ap::_vdotproduct<ap::complex>(v1, v2, N);
}
void ap::vmove(double *vdst, const double* vsrc, int N)
{
#ifdef AP_WIN32
if( dmove1!=NULL )
{
dmove1(vdst, vsrc, N);
return;
}
#endif
ap::_vmove<double>(vdst, vsrc, N);
}
void ap::vmove(ap::complex *vdst, const ap::complex* vsrc, int N)
{
ap::_vmove<ap::complex>(vdst, vsrc, N);
}
void ap::vmoveneg(double *vdst, const double *vsrc, int N)
{
#ifdef AP_WIN32
if( dmoveneg1!=NULL )
{
dmoveneg1(vdst, vsrc, N);
return;
}
#endif
ap::_vmoveneg<doubl
没有合适的资源?快使用搜索试试~ 我知道了~
计算特殊矩阵的逆的程序
共13个文件
h:5个
html:4个
cpp:3个
需积分: 10 3 下载量 67 浏览量
2008-12-18
10:36:03
上传
评论
收藏 37KB ZIP 举报
温馨提示
快速求解(单位)上下三角矩阵的逆的C++程序
资源详情
资源评论
资源推荐
收起资源包目录
trinverse[1].cpp.zip (13个子文件)
faq.english.html 13KB
trinverse.h 4KB
tests
testtrinverse.h 727B
testtrinverse.cpp 6KB
libs
apvt.h 21KB
stdafx.h 0B
ap.english.html 22KB
ap.h 18KB
ap.cpp 13KB
ap.russian.html 22KB
trinverse.cpp 10KB
faq.russian.html 15KB
license 53B
共 13 条
- 1
zhaomx
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0