String数据转Matrix矩阵
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矩阵的更多相关文章
- Leetcode 566. Reshape the Matrix 矩阵变形(数组,模拟,矩阵操作)
Leetcode 566. Reshape the Matrix 矩阵变形(数组,模拟,矩阵操作) 题目描述 在MATLAB中,reshape是一个非常有用的函数,它可以将矩阵变为另一种形状且保持数据 ...
- 汉高澳大利亚matrix矩阵计算器
我在梦中的超级计算机超级计算机锯,使用大量阵列的cpu记忆,完成并行计算.一个手机制造商由于使用普通机械提供的服务,往往造成停机.是铁道部列车网络售票的事实. 无法使用云服务.上万台计算机并行处理,因 ...
- 【CSS3】 理解CSS3 transform中的Matrix(矩阵)
理解CSS3 transform中的Matrix(矩阵) by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu ...
- 理解CSS3 transform中的Matrix(矩阵)
一.哥,我被你吓住了 打架的时候会被块头大的吓住,学习的时候会被奇怪名字吓住(如“拉普拉斯不等式”).这与情感化设计本质一致:界面设计好会让人觉得这个软件好用! 所以,当看到上面“Matrix(矩阵) ...
- HDU5015 233 Matrix(矩阵高速幂)
HDU5015 233 Matrix(矩阵高速幂) 题目链接 题目大意: 给出n∗m矩阵,给出第一行a01, a02, a03 ...a0m (各自是233, 2333, 23333...), 再给定 ...
- 理解CSS3 transform中的Matrix(矩阵)——张鑫旭
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=2427 一.哥,我被你 ...
- List<实体>与List<String>数据互转
1.List<实体>数据: public List<Device> queryOSDevice(String cpu,String ip,String name){ Strin ...
- Android中的Matrix(矩阵)
写在前面 看这篇笔记之前先看一下参考文章,这篇笔记没有系统的讲述矩阵和代码的东西,参考文章写的也有错误的地方,要辨证的看. 如何计算矩阵乘法 android matrix 最全方法详解与进阶(完整篇) ...
- String数据类型转换
String是final类,提供字符串不可修改.强制类型转换,String类型无处不在.下面介绍一些常见的String数据类型转换. String数据类型转换成long.int.double.floa ...
随机推荐
- Redis实现高并发下的抢购、秒杀功能
博主最近在项目中遇到了抢购问题!现在分享下.抢购.秒杀是如今很常见的一个应用场景,主要需要解决的问题有两个:1 高并发对数据库产生的压力2 竞争状态下如何解决库存的正确减少("超卖" ...
- TCP协议三次握手连接四次握手断开和DOS攻击
转载:http://blog.csdn.net/fw0124/article/details/7452695 TCP连接的状态图 TCP建立连接的三次握手过程,以及关闭连接的四次握手过程 贴一个tel ...
- 删除emacs临时文件
emacs编辑文件后产生的带小尾巴(~)的文件,你有没有强迫症,要删之而后快rm -rf *~ 你有没有不小心敲成了rm -rf ~,然后爽快的按下了回车,然后欲哭无泪,哈哈- 其实,可以设置在ema ...
- Alpha冲刺(六)
Information: 队名:彳艮彳亍团队 组长博客:戳我进入 作业博客:班级博客本次作业的链接 Details: 组员1(组长)柯奇豪 - 过去两天完成了哪些任务 1. 基于ssm框架的前后端交互 ...
- mysql 循环插入
在mysql添加测试数据,想和mssql一样用循环实现,发现不管怎么样都执行失败 经查询发现mysql不支持匿名块,只能先创建出一个存储过程,执行,然后删除 CREATE PROCEDURE test ...
- 理解ASP.NET MVC引擎处理模型字符串的默认行为,涉及Html.Raw()和HttpUtility.HtmlDecode()
MVC引擎默认会将Model属性值中包含的html字符串做encode,所以如属性中包含类似 <br> 这样的标记,MVC引擎会将它们转换成html实体码 %3Cbr%3E 所以1:在编辑 ...
- docker-compose 命令
docker-compose初试及命令基础 以一个简单的lnmp.yaml的配置文件进行讲解docker-compose命令的基础讲解,熟练掌握命令 [root@docker lnmp]# cat l ...
- 用FileZilla服务器端和客户端实现本机与虚拟机之间文件上传和下载
1. FileZilla简介 2.准备工作3.安装 FileZilla Server和配置3.1.问题及解决方法3.2.添加目录3.3.测试FIP4.安装FileZilla Client5.连接服务器 ...
- Windows上编译libpng
下载libpng 1.5.10并解压到[工作目录]/png/libpng-1.5.10 用CMake选择png/libpng-1.5.10目录并Configure: CMAKE_C_FLAGS_DEB ...
- Win8.1下安装sql server 2008 r2详解
我是来斗图的,安装了好多次,有一些配置还是不能烂熟于心啊,所以就想起来了米老师那句话,学习是个反复的过程.写个教程吧,很简单但是很实用. 首先打开"setup.exe"出现以下界面 ...