100分求矩阵运算的C++库

oldboy1234 2004-12-30 08:45:59
哪里有免费的C++矩阵运算的库,可以在VC6.0下编译通过的?
...全文
309 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhengwei1984222 2004-12-31
  • 打赏
  • 举报
回复
我想知道为什么不用matlab
可以生成c代码的
oldboy1234 2004-12-30
  • 打赏
  • 举报
回复
刚才查了Blitz的官方网站,不支持VC6.0啊
Visual C++ 6.0. Does not support member templates outside of class declarations, and crashes (CRASHES!) if you try to do so. Definitely not recommended.
xuzheng318 2004-12-30
  • 打赏
  • 举报
回复
http://www.osl.iu.edu/research/mtl/
The Matrix Template Library, 比Fortran 90还快的矩阵运算程序库

http://www.netlib.org

http://math.nist.gov/tnt
goodluckyxl 2004-12-30
  • 打赏
  • 举报
回复
矩阵的计算用STL可以很好的实现
效率可以很高
但是如果使用编译期进行求值
可能效率会很差很差

求特征根,秩,逆这些涉及的相对复杂
自己实现考虑异常不小的工作量
-_-#

oldboy1234 2004-12-30
  • 打赏
  • 举报
回复
Blitz库我有了,不过感觉好复杂,就是想找一个简单点的库,支持基本运算即可
oldboy1234 2004-12-30
  • 打赏
  • 举报
回复
谢谢楼上的,不过我需要一些稍微复杂的运算,比如求矩阵的特征根,求矩阵的逆这些。效率上不需要考虑多少,计算量不是很大。我本来找了个metaware,是linux下的,可惜库中用了模版的偏特化,而VC6.0又不支持,郁闷。
BluntBlade 2004-12-30
  • 打赏
  • 举报
回复
使用Blitz库吧。
goodluckyxl 2004-12-30
  • 打赏
  • 举报
回复
//以前写的部分矩阵 ,对于矩阵运算 应该采用延迟策略来的比较好一些
//自己考虑考虑
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <assert.h>
class Matrix
{
public:
Matrix();
Matrix( int RowRecord, int ColRecord );
~Matrix();

Matrix& operator = ( Matrix& OneMatrix );
Matrix& operator +=( Matrix& OneMatrix );
friend ostream& operator << ( ostream& os, Matrix& TheMatrix );

private:
void InitMatrix();
void DestoryMatrix();
private:
int RowLength;
int ColLength;
int** DataStore;
};

Matrix::Matrix()
{
RowLength = 0;
ColLength = 0;
DataStore = 0;
}

Matrix::Matrix( int RowRecord, int ColRecord )
{
assert( RowRecord != 0 && ColRecord != 0 );
RowLength = RowRecord;
ColLength = ColRecord;
InitMatrix();
}

void Matrix::InitMatrix()
{
DataStore = new int*[RowLength];
for( int Num = 0; Num < RowLength; Num++ )
{
try
{
*(DataStore+Num) = new int[ColLength];
memcpy( DataStore+Num, 0, ColLength*sizeof(int) );
}
catch (...)
{
for( int i = Num-1; i >= 0; i--)
delete[] *(DataStore+i);

delete[] DataStore;
}
}


}
void Matrix::DestoryMatrix()
{
if( ColLength*RowLength != 0 )
{

for( int i = ColLength-1; i >= 0; i-- )
{
delete[] *(DataStore+i);
}
delete[] DataStore;

}
}

Matrix::~Matrix()
{
DestoryMatrix();
}

Matrix& Matrix::operator += (Matrix& OneMatrix )
{
if( RowLength != OneMatrix.RowLength || ColLength != OneMatrix.ColLength )
{
return *this;
}
else
{
for( int i = 0; i < RowLength; i++ )
{
for( int j = 0; j < ColLength; j++ )
{
*(*(DataStore+i)+j) += *(*(OneMatrix.DataStore+i)+j);
}
}
return *this;
}
}

Matrix& Matrix::operator = ( Matrix& OneMatrix )
{
DestoryMatrix();
RowLength = OneMatrix.RowLength;
ColLength = OneMatrix.ColLength;

InitMatrix();
*this += OneMatrix;
return *this;
}

ostream& operator << ( ostream& os, Matrix& TheMatrix )
{
for( int i = 0; i < TheMatrix.RowLength; i++ )
{
for( int j = 0; j < TheMatrix.ColLength; j++ )
{
os<<*(*(TheMatrix.DataStore+i)+j);
}
os<<endl;
}
return os;
}

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧