我刚刚开始使用PDL,并在文档中看到导入PDL的核心功能有两种可能的方法:
use PDL::Core;
use PDL::Core ':Internal';这里到底有什么区别?文档对第二种方法进行了评论:“毛茸茸例程”。我也找不到任何关于这意味着什么的东西。
发布于 2022-07-04 23:30:20
use PDL::Core;等于
use PDL::Core ':Func';这相当于
use PDL::Core
qw( piddle pdl null barf ),
( map $_->convertfunc, PDL::Types::types() ),
qw(
nelem dims shape null empty dup dupN inflateN
convert inplace zeroes zeros ones nan inf i list listindices unpdl
set at flows broadcast_define over reshape dog cat barf type
thread_define dummy mslice approx flat sclr squeeze
get_autopthread_targ set_autopthread_targ get_autopthread_actual
get_autopthread_dim get_autopthread_size set_autopthread_size
);use PDL::Core ':Internal';等于
use PDL::Core qw( howbig broadcastids topdl );发布于 2022-07-05 17:36:26
正如@ikegami所说,
use PDL::Core ':Internal';实际上相当于
use PDL::Core qw( howbig broadcastids topdl );在实现代码论GitHub中可以看到这一点。--然而,--也可以看到,use PDL::Core;引入的不仅仅是qw(piddle pdl null barf)。
这三个“内部”例程分别给出了给定PDL的多少字节--内部数据类型ID ( ndarray中的维度已被标记为广播),并将任何Perl值转换为ndarray (如果它尚未被标记为ndarray)。最后两个方法可能总是被调用为一个方法(分别是对象和类),而第一个方法对于普通的PDL使用(通常是数学-y)并不有用。它们仍然可以通过PDL::Core包获得,只是没有导出。
一般来说,不推荐显式导入PDL::Core,也不推荐导入任何“核心”PDL包(PDL::Primitive、PDL::Ops等);而是导入PDL::LiteF (仅导出最小函数)或PDL::Lite (不导出函数)中的一个。出于历史原因,use PDL导入额外的非“核心”包(如PDL::IO::FITS )。
https://stackoverflow.com/questions/72862648
复制相似问题