Perl PDL 胶水不起作用?

发布于 2024-12-22 04:15:24 字数 895 浏览 3 评论 0原文

我是 PDL 新手,请原谅我的基本问题:

我有两个简单的 pdl 对象,

pdl> p $a                                                                                                                    

[
  [1 2 3]
  [4 5 6]
]

pdl> p $c                                                                                                                    
[6 6 6]

我将它们粘合在一起并返回我期望的结果

pdl> p glue $b, $c                                                                                                           

 [
  [1 2 3]
  [4 5 6]
 ]
 [6 6 6]

但是,当我将粘合分配给变量 $z 时,粘合不粘。

 $z = glue $b, $c  


 pdl> p $z                                                                                                                    

 [
  [1 2 3]
  [4 5 6]
 ]

我缺少什么?

我的最终目标是通过使用glue、cat 或append 循环文件来构建一个大的piddle。

I am new to PDL and please forgive my rudimentary question:

I have two simple pdl objects

pdl> p $a                                                                                                                    

[
  [1 2 3]
  [4 5 6]
]

pdl> p $c                                                                                                                    
[6 6 6]

I glue them together and return what I expect

pdl> p glue $b, $c                                                                                                           

 [
  [1 2 3]
  [4 5 6]
 ]
 [6 6 6]

However, when I assign the glue to a variable $z the glue doesn't stick.

 $z = glue $b, $c  


 pdl> p $z                                                                                                                    

 [
  [1 2 3]
  [4 5 6]
 ]

What am I missing?

My ultimate goal is to build a large piddle by looping through a file using glue, cat or append.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哎呦我呸! 2024-12-29 04:15:24

这不是使用glue()的方式。 来自文档

$c = $a->glue(,$b,...)

我相信你必须这样做 $z = $b->glue(1,$c)< /代码>。不过,我对 参数有点不确定;尝试使用它,看看会发生什么。

编辑:是的,您可以使用 1

pdl> $a = pdl [[1,2,3],[4,5,6]];

pdl> p $a

[
 [1 2 3]
 [4 5 6]
]

pdl> $c = pdl [6,6,6];

pdl> p $c
[6 6 6]
pdl> $z = $a->glue(1,$c);

pdl> p $z

[
 [1 2 3]
 [4 5 6]
 [6 6 6]
]

That's not how you use glue(). From the docs:

$c = $a->glue(<dim>,$b,...)

I believe you would have to do something like $z = $b->glue(1,$c). I'm a little unsure about the <dim> parameter though; try playing around with it and see what happens.

Edit: Yeah, you would use a <dim> of 1:

pdl> $a = pdl [[1,2,3],[4,5,6]];

pdl> p $a

[
 [1 2 3]
 [4 5 6]
]

pdl> $c = pdl [6,6,6];

pdl> p $c
[6 6 6]
pdl> $z = $a->glue(1,$c);

pdl> p $z

[
 [1 2 3]
 [4 5 6]
 [6 6 6]
]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文