河池网站制作,网站建设亿金手指花总14,中国商标网注册官网,企业文化ppt模板免费原文:【原创】开源Math.NET基础数学类库使用(04)C#解析Matrix Marke数据格式开源Math.NET基础数学类库使用系列文章总目录#xff1a; 1.开源.NET基础数学计算组件Math.NET(一)综合介绍 2.开源.NET基础数学计算组件Math.NET(二)矩阵向量计算 3.开源.NET基础数学计算组件Ma…原文:【原创】开源Math.NET基础数学类库使用(04)C#解析Matrix Marke数据格式 开源Math.NET基础数学类库使用系列文章总目录 1.开源.NET基础数学计算组件Math.NET(一)综合介绍 2.开源.NET基础数学计算组件Math.NET(二)矩阵向量计算 3.开源.NET基础数学计算组件Math.NET(三)C#解析Matlab的mat格式 4.开源.NET基础数学类库使用Math.NET(四)C#解析Matrix Marke数据格式 5.开源.NET基础数学类库使用Math.NET(五)C#解析Delimited Formats数据格式 6.开源.NET基础数学类库使用Math.NET(六)数值分析之线性方程直接求解 7.开源.NET基础数学类库使用Math.NET(七)常用的一些数学常数 8.开源.NET基础数学类库使用Math.NET(八)C#进行数值积分 9.开源.NET基础数学类库使用Math.NET(九)相关数论函数使用 10.开源.NET基础数学类库使用Math.NET(十)C#进行数据统计 11.开源.NET基础数学类库使用Math.NET(十一)C#计算相关系数 12.开源.NET基础数学类库使用Math.NET(十二)随机数扩展方法 13.开源.NET基础数学类库使用Math.NET(十三)C#实现其他随机数生成器 14.开源.NET基础数学类库使用Math.NET(十四)安全的随机数生成器扩展 后续继续更新中。。如文章链接打开有误请关注博客因为文章正在编辑修改中所有已经列出的目录都将在1个月之内发表。 前言 上一篇文章我们介绍了使用C#读写Matlab的Mat数据格式的情况。mat格式的广泛应用使得很多人都了解但同样还有一些数据格式也是在科学计算数据分析测试等方面的通用数据格式那就是接下来我们要介绍的Matrix Market格式。我们同样是使用C#来操作该格式。 如果本文资源或者显示有问题请参考 本文原文地址http://www.cnblogs.com/asxinyu/p/4266758.html 1.Matrix Market格式介绍 Matrix Market是一个基于AscII的可读性很强的文件格式目的是促进矩阵数据的交流。NIST的数据存储就有大量的数值线性代数相关的研究比较测试数据采用该格式。其他信息可以参考官网http://math.nist.gov/MatrixMarket/ http://en.wikipedia.org/wiki/Matrix_Market_exchange_formats The Matrix Market exchange formats are a set of human readable, ASCII-based file formats designed to facilitate the exchange of matrix data. The file formats were designed and adopted for the Matrix Market, a NIST repository for test data for use in comparative studies of algorithms for numerical linear algebra。 下面是一个Matrix Market矩阵的部分截图可以直接的理解该格式的确是非常人性化也方便不同软件系统间的数据交换。 2.C#读取Matrix Market文件 本文还是使用Math.NET提供的程序只不过对其结构和使用进行分析。C#读取的返回值的矩阵或者向量格式也都是Math.NET中的类型。C#读取Martix Market文件的主要类型是MatrixMarketReader在MathNet.Numerics.Data.Text项目中而其中的方法都是静态方法分别为读取矩阵和读取向量并支持从文件和流中分别读取数据。看看如下几个静态函数的原型就可以知道怎么样了 1 public static MatrixT ReadMatrixT(string filePath,Compression compressionCompression.Uncompressed) where T : struct, IEquatableT, IFormattable2 3 public static VectorT ReadVectorT(string filePath,Compression compressionCompression.Uncompressed) where T : struct, IEquatableT, IFormattable4 5 public static MatrixT ReadMatrixT(Stream stream) where T :struct,IEquatableT,IFormattable6 7 public static VectorT ReadVectorT(Stream stream) where T :struct,IEquatableT,IFormattable8 9 public static MatrixT ReadMatrixT(TextReader reader) where T :struct,IEquatableT,IFormattable
10
11 public static VectorT ReadVectorT(TextReader reader) where T :struct,IEquatableT,IFormattable 上面要注意的是该文件支持压缩所以有一个Compression参数默认是未压缩的。 3.C#保存数据为Matrix Market文件 C#写入Matrix Market文件的方法和上面的读取类似使用的是MatrixMarketWriter类的静态方法支持写入矩阵和向量方法原型如下 1 public static void WriteMatrixT(string filePath, MatrixT matrix, Compression compression Compression.Uncompressed) where T : struct, IEquatableT, IFormattable2 3 public static void WriteVectorT(string filePath, VectorT vector, Compression compression Compression.Uncompressed) where T : struct, IEquatableT, IFormattable4 5 public static void WriteMatrixT(Stream stream, MatrixT matrix) where T : struct, IEquatableT, IFormattable6 7 public static void WriteVectorT(Stream stream, VectorT vector) where T:struct,IEquatableT,IFormattable8 9 public static void WriteMatrixT(TextWriter writer,MatrixT matrix) where T :struct,IEquatableT, IFormattable
10
11 public static void WriteVectorT(TextWriter writer, VectorT vector) where T :struct,IEquatableT, IFormattable 一般来说写入文件比较常用一点可以用于系统之间和样本数据的传递。总共就2个类常用的也就4个方法使用C#操作该数据格式就可以无忧了。 4.资源 源码下载参考官网网站。 如果本文资源或者显示有问题请参考 本文原文地址http://www.cnblogs.com/asxinyu/p/4266758.html 本博客还有大量的.NET开源技术文章您可能感兴趣 1.开源Math.NET基础数学类库使用系列文章链接 2.开源C#彩票数据资料库系列文章链接 3.开源的.NET平台ORM组件文章链接 4.其他开源的.NET组件文章链接 5..NET平台机器学习组件-Infer.NET系列文章链接 6.Matlab混合编程文章链接