如何从CSML矩阵中检索值? [英] How to retrieve a value from CSML matrix?

查看:77
本文介绍了如何从CSML矩阵中检索值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CSML进行矩阵乘法.
在某些时候,我必须从矩阵中检索特定的索引值,但是我无法检索它.

我使用的方法是:

public static int matrix2int(Matrix m,int i,int j)
{
返回(int)m.Row(i).Values [j-1];//将Arraylist广播到int
}

生成的错误无法将Arraylist强制转换为int.
CSML的开发人员可以帮助我做到这一点吗?


等待您的答案

i am using CSML for matrix multiplication.
at certain points i have to retrieve a specific indexed value from the matrix but i am unable to retrieve it.

the method i am using is:

public static int matrix2int(Matrix m, int i, int j)
{
return (int)m.Row(i).Values[j-1];//casting Arraylist to int
}

the error being generated is can not cast Arraylist to int.
can the developer of CSML help me out how to do it.


waiting for your answer

推荐答案

以这种方式尝试"

return(int)(m.Row(i).Values [j-1]);

Essentailly,将ArrayList中的值转换为int而不是将ArrayList转换为int.
try it this way"

return (int)(m.Row(i).Values[j-1]);

Essentailly, cast the value in the ArrayList as an int instead of casting the ArrayList as an int.


Innayat Ullah写道:
Innayat Ullah wrote:

CSML的开发人员可以帮助我如何做吗.

can the developer of CSML help me out how to do it.



而且您认为这个人,无论他是谁,都会无处不在并看到您的消息?



And you think this person, whoever he is, is going to appear from nowhere and see your message?


那么您可能需要进行一些错误处理了...

如果从m.Row(i).Values [j-1]返回的值始终是int?如果不是,那么我给出的代码将出错,因为我们假定在转换时该值是一个int值.

您可能要尝试Int32.Parse(m.Row(i).Values [j-1])或Int32.TryParse().

找出是否有异常被抛出,找出矩阵中的值,等等.
Well you may need to do some error handling then...

If the value returned from m.Row(i).Values[j-1] always an int? If not, then the code I gave will error, because we assume that the value is an int when we cast it.

You might want to try Int32.Parse(m.Row(i).Values[j-1]) or Int32.TryParse().

Figure out if there is some exception being thrown, figure out what the value is in the matrix, etc.


这篇关于如何从CSML矩阵中检索值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆