矩阵元素全部显示及提取


请问,如何显示矩阵的全部元素?感谢回答。

julia> a = rand(100);
julia> summary(a)
"100-element Vector{Float64}"
julia> show(stdout, "text/plain", a)
100-element Vector{Float64}:
 0.13289313875774322
 0.8569473161094071
 0.8562610079815618
 0.39270608514453986
 0.5936526552624308
 0.3285104177467949
 0.09852214845638874
 0.933449250010462
 0.5714034147464212
 0.9691668740452063
 0.6062864903483952
 0.03366158814751741
 0.5729427603767858
 0.6109178957053985
 0.9201922109018131
 0.5025855838832151
 0.8939341081721716
 0.48480346295902266
 0.6358247638246308
 0.7371281221880833
 0.5076008241535469
 0.8698946218906418
 0.020630715648127573
 0.5721221883962283
 0.353041790626786
 0.8474938716455723
 0.42616980975686025
 0.14188424108871578
 0.8509955958542627
 0.4939988692928503
 0.5350395918501131
 0.919305262245936
 0.5932536778844841
 0.172008864275215
 0.28096833470660965
 0.2601007757883088
 0.996002578767539
 0.30537528137542513
 0.2479832519092081
 0.9761688566343462
 0.9291753321582332
 0.3621332894999777
 0.8870061313355991
 0.23147050831323035
 0.0874200863741521
 0.32668421964101024
 0.41076334201834264
 0.01702248645298876
 0.9427125855121913
 0.2718976225768681
 0.9059717952566877
 0.5500985029130667
 0.464316130587066
 0.939413377841242
 0.2191551981985802
 0.9682944719810731
 0.9388953109783069
 0.6797153137416906
 0.6277502214359784
 0.7897167537859234
 0.2922182097894388
 0.636315948056847
 0.5185352108271682
 0.8533779622505562
 0.9886486677459012
 0.7206674746819767
 0.08035213744879244
 0.7094109216697355
 0.9058278334985478
 0.30591808717045454
 0.9064403782563473
 0.4161995541531013
 0.6420075178677647
 0.5806505877681346
 0.12481125723726882
 0.408122390687954
 0.8645353218084124
 0.5392938784805922
 0.9840492667230244
 0.690322642649319
 0.3320887057531162
 0.4973866924317024
 0.6545001828159991
 0.9743049138836842
 0.6530930870955901
 0.7829098825283967
 0.4155192977611991
 0.8522073401514366
 0.16566744177381187
 0.6710921907557406
 0.6029949572080471
 0.5420112417268879
 0.0873390970814093
 0.535767136946077
 0.5966383999776858
 0.48048799802405806
 0.5934398975888079
 0.5298649035133774
 0.4275387617734173
 0.05563027754907446
1 个赞

TerminalPager.jl

julia> a = rand(100);

julia> a |> pager

和上面的方案有些不同,不是同时显示的,和 man 命令的操作方式类似。

See Provide a simple way to print all entries in a collection · Issue #29223 · JuliaLang/julia · GitHub

macro showall(expr)
    return quote
        show(IOContext(stdout, :compact => false, :limit => false), "text/plain", $(esc(expr)))
    end
end

@showall rand(100, 100)

我还在Issue里面看到了println.(x);的写法。

也挺奇怪为啥他们不觉得这个需要简单解决一下。

这是 taste 吧,Python 也有这个问题,或者说他们不觉得是问题:python - How do I print the full NumPy array, without truncation? - Stack Overflow