String数据转Matrix矩阵

private Matrix String_To_Matrix(string str)

{

int[] Remove_Num = new int[10];

int Remove_Int = 0;

string Str_One = str;

//{ {M11:1 M12:0 M13:0 M14:0} {M21:0 M22:1 M23:0 M24:0} {M31:0 M32:0 M33:1 M34:0} {M41:0 M42:0 M43:0 M44:1} }

//string Str_One = "{ {M11:1 M12:0 M13:0 M14:0} {M21:0 M22:1 M23:0 M24:0} {M31:0 M32:0 M33:1 M34:0} {M41:0 M42:0 M43:0 M44:1} }";

for (int i = 0; i < Str_One.Length; i++)

{

//string str = Str_One[i].ToString ();

if (Str_One[i].Equals('{') || Str_One[i].Equals('}'))

{

Remove_Num[Remove_Int] = i;

Remove_Int += 1;

}

}

Remove_Int = 0;

int Remove_num_int = 0;

string Str_Two = "";// M11:1 M12:0 M13:0 M14:0 M21:0 M22:1 M23:0 M24:0 M31:0 M32:0 M33:1 M34:0 M41:0 M42:0 M43:0 M44:1

foreach (var item in Remove_Num)

{

//string str = item.ToString();

Remove_num_int = item - Remove_Int;

Str_Two = Str_One.Remove(Remove_num_int, 1);

Str_One = Str_Two;

Remove_Int += 1;

}

string[] M_int = new string[16];// 1 0 0 0 ,0 1 0 0 ,0 0 1 0 ,0 0 0 1

for (int i = 0; i < 16; i++)

{

M_int[i] = (Str_Two.Split(' ')[i + 1]).Split(':')[1];

}

//Matrix aaaa = new Matrix(0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1);

Matrix new_Matrix = new Matrix(float.Parse(M_int[0]), float.Parse(M_int[1]), float.Parse(M_int[2]), float.Parse(M_int[3]), float.Parse(M_int[4]), float.Parse(M_int[5]), float.Parse(M_int[6]), float.Parse(M_int[7]), float.Parse(M_int[8]), float.Parse(M_int[9]), float.Parse(M_int[10]), float.Parse(M_int[11]), float.Parse(M_int[12]), float.Parse(M_int[13]), float.Parse(M_int[14]), float.Parse(M_int[15]));

return new_Matrix;

}

注:取Matrix格式string字符串,循环判断添加索引int[]数组,去除‘{}',再根据’  ‘进行对整体string分割取string[],之后依据':'分割读取float于float[]数组,对新建Matrix依次赋值,达到string转matrix效果.....

String数据转Matrix矩阵的更多相关文章

  1. Leetcode 566. Reshape the Matrix 矩阵变形(数组,模拟,矩阵操作)

    Leetcode 566. Reshape the Matrix 矩阵变形(数组,模拟,矩阵操作) 题目描述 在MATLAB中,reshape是一个非常有用的函数,它可以将矩阵变为另一种形状且保持数据 ...

  2. 汉高澳大利亚matrix矩阵计算器

    我在梦中的超级计算机超级计算机锯,使用大量阵列的cpu记忆,完成并行计算.一个手机制造商由于使用普通机械提供的服务,往往造成停机.是铁道部列车网络售票的事实. 无法使用云服务.上万台计算机并行处理,因 ...

  3. 【CSS3】 理解CSS3 transform中的Matrix(矩阵)

    理解CSS3 transform中的Matrix(矩阵) by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu ...

  4. 理解CSS3 transform中的Matrix(矩阵)

    一.哥,我被你吓住了 打架的时候会被块头大的吓住,学习的时候会被奇怪名字吓住(如“拉普拉斯不等式”).这与情感化设计本质一致:界面设计好会让人觉得这个软件好用! 所以,当看到上面“Matrix(矩阵) ...

  5. HDU5015 233 Matrix(矩阵高速幂)

    HDU5015 233 Matrix(矩阵高速幂) 题目链接 题目大意: 给出n∗m矩阵,给出第一行a01, a02, a03 ...a0m (各自是233, 2333, 23333...), 再给定 ...

  6. 理解CSS3 transform中的Matrix(矩阵)——张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=2427 一.哥,我被你 ...

  7. List<实体>与List<String>数据互转

    1.List<实体>数据: public List<Device> queryOSDevice(String cpu,String ip,String name){ Strin ...

  8. Android中的Matrix(矩阵)

    写在前面 看这篇笔记之前先看一下参考文章,这篇笔记没有系统的讲述矩阵和代码的东西,参考文章写的也有错误的地方,要辨证的看. 如何计算矩阵乘法 android matrix 最全方法详解与进阶(完整篇) ...

  9. String数据类型转换

    String是final类,提供字符串不可修改.强制类型转换,String类型无处不在.下面介绍一些常见的String数据类型转换. String数据类型转换成long.int.double.floa ...

随机推荐

  1. pig(数据流语言和编译器)学习https://www.w3cschool.cn/apache_pig/apache_pig_execution.html

    当我们配置了hadoop集群执行的时候 可以通过命令ls进行查看 存储语法 STORE Relation_name INTO ' required_directory_path ' [USING fu ...

  2. XE5应用开发支持的安卓设备

    XE5应用开发支持的安卓设备 A.官方文档声明 RADStudio 支持Android设备的应用开发,android版本从2.3到4.3.x,ARMv7处理器,MEON支持.根据Embarcadero ...

  3. Linq集合操作之Intersect,Except,Union源码分析

    Linq集合操作之Intersect,Except,Union源码分析 linq的集合运算 常见的集合运算有哪些? 这三个扩展方法在我们实际使用中用的还是非常多的,而且这里还涉及到了“复杂度” 无算法 ...

  4. 利用PhotoShop对大图像进行等分切片

    图文介绍利用PhotoShop等分切图 1.调用切片工具,右键选择划分切片 2.指定水平划分.垂直划分的等分数量,点击确定 3.在文件菜单中选择存储为... 4.配置图像质量参数.点击存储.指定存储位 ...

  5. Postgres数据库在Linux中优化

    I/O 优化1 打开 noatime nodirtime,async 方法: 修改 /etc/fstab stat 命令查看 2 调整预读方法: 查看 sudo blockdev --getra /d ...

  6. 通用性站点管理后台(Bee OPOA Platform) (5)- 【扩展】基于WebSocket的监视Sql执行功能

    开始 底层的东西总是很类似, 看了园里的Fish-Li的一系列文章, 写得真好, 无论是风格还是内容. 本来也想想方便点就用remoting实现监视功能算了, 但这样就需要一个Winform的项目了. ...

  7. Transaction And Lock--死锁错误号1205

    在TSQL中,如果需要判断当前错误是否是因为死锁引起,可以使用ERROR_NUMBER()=1205来判断在C#中,使用SQLException来捕获 SQLException.Number=1205 ...

  8. Java集合框架(Collection Framework)学习之 HashMap

    从API文档可以得到HashMap的以下几个特点: 基于哈希表(hash table)实现,并且是链式哈希表 允许空值和空键(null=null 键值对) HashMap与Hashtable基本相同, ...

  9. kali linux之Bdfproxy

    Bdfproxy(mitmproxy) 基于流量劫持动态注入shellcode(arp欺骗,dns欺骗,流氓ap) 步骤: 开启流量转发---------sysctl -w net.ipv4.ip_f ...

  10. php面试题汇集2

    1.实现中文字符串截取无乱码方法 开启mbstring扩展,然后自定义函数: <?php header('content-Type:text/html:charset=utf-8'); func ...