如何将矩阵更改为PDL数据结构? [英] How to change a matrix into a PDL data structure?

查看:142
本文介绍了如何将矩阵更改为PDL数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我刚刚学习了如何使用PDL.问题是我的数据(矩阵)在外部文件中.
如何将其更改为PDL数据结构?
我尝试了下面的代码,但是$ s中的值仍然是1.


Hello,

I just learned how to use PDL. The problem is that my data (matrix) is in an external file.
How can i change change it into a PDL data structure?
I tried the code below but, the values in $s are still ones.


use PDL;
use PDL::Matrix;
use PDL::NiceSlice;
use PDL::AutoLoader;
use PDL::IO::Dumper;

my $s = ones(10,10); # There are 10 columns and 10 rows
my $k = 0;
while (my $line = <$fileHandler>)
{
        $s(0:9,0:$k) = $line;
        $k++;
}



致谢,谢谢您,

Herve



Regards and thank you,

Herve

推荐答案

仍然是一个.


s are still ones.


use PDL;
use PDL::Matrix;
use PDL::NiceSlice;
use PDL::AutoLoader;
use PDL::IO::Dumper;

my


s =个(10,10); #有10列和10行 my
s = ones(10,10); # There are 10 columns and 10 rows my


k = 0; 而(我的
k = 0; while (my


这篇关于如何将矩阵更改为PDL数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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