【c#】 5. Tensor数据(用于Excel中不同sheet中都有矩阵的情况)
2015-02-28 20:40
411 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace UserDefinedDataEXP { class Tensor<T> { private int m_rows; private int m_columns; private int m_depth; private Array<NumericMatrix<T>> m_tensor; // Constructor with #rows, columns and depth, all startindexes = 1. //每个矩阵都是rows*columns,在这个数组中nthird个 public Tensor(int rows, int columns, int nthird) { m_tensor = new Array<NumericMatrix<T>>(nthird, 1); for (int i = m_tensor.MinIndex; i <= m_tensor.MaxIndex; i++) { m_tensor[i] = new NumericMatrix<T>(rows, columns, 1, 1); } m_rows = rows; m_columns = columns; m_depth = nthird; } public NumericMatrix<T>this[int depth] { get { return m_tensor[depth]; } set { m_tensor[depth] = value; } } //MinThirdIndex属性 public int MinThirdIndex { get { return 1; } } //MaxThirdIndex属性 public int MaxThirdIndex { get { return m_depth; } } } }
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Diagnostics;namespace UserDefinedDataEXP{ class test { static void Main(string[] args) { // Tensors, calculate powers of a matrix and print int nrows = 2; int ncols = 2; int ndepth = 100; NumericMatrix<double> T = new NumericMatrix<double>(nrows, ncols); T[1, 1] = 1.0; T[2, 2] = 1.0; T[1, 2] = .001; T[2, 1] = 0.0; Tensor<double> myT = new Tensor<double>(nrows, ncols, ndepth); myT[myT.MinThirdIndex] = T; for (int j = myT.MinThirdIndex + 1; j <= myT.MaxThirdIndex; j++) { myT[j] = T * myT[j - 1]; } for (int j = myT.MinThirdIndex + 1; j <= myT.MaxThirdIndex; j++) { // Print every tenth matrix in tensor if ((j / 10) * 10 == j) { myT[j].print(); Console.WriteLine(); } } Console.Read(); } }
相关文章推荐
- C# 如何将 不同的数据(多个查询结果集 dataset)导出到一个excel的不同sheet中
- ABAP中读取EXCEL中不同的SHEET数据
- ABAP中读取EXCEL中不同的SHEET数据
- ABAP中读取EXCEL中不同的SHEET数据
- C#使用Gembox.SpreadSheet向Excel写入数据及图表的实例
- Jxls导出excel的若干方式总结(十一)-- 同一个sheet中显示来自不同数据表的对象记录
- 【利用Python进行数据分析——经验篇4】将多张DataFrame表写入到同一个Excel的不同sheet中
- 微软BI 之SSIS 系列 - 通过 OLE DB 连接访问 Excel 2013 以及对不同 Sheet 页的数据处理
- phpexcel 读取含多个sheet的excel,将从数据库中检索出的数据分别写入该excel不同的sheet中 并导出该excel
- C#用Oledb查询Excel某个sheet中的数据——按多个条件查询
- C#向excel的指令表单sheet指定行列中写入数据
- [C#] Gembox.SpreadSheet向Excel写入数据及图表
- 考试系统--导出Dataset的数据到Excel的不同sheet中
- C# 使用OLEDB读取不同版本Excel数据的连接字符串
- C# 读取 excel 中 sheet 及数据到DataTable
- ABAP中读取EXCEL中不同的SHEET数据
- C#操作Excel数据导入(不安装EXCEL的情况)
- [C#]使用Gembox.SpreadSheet向Excel写入数据及图表
- DataGrid中的数据导入到Word和Excel_C#
- 使用 Visual C# .NET 向 Excel 工作簿传输数据