您如何制作视图尺寸? [英] How do you make a view drop dimensions?
本文介绍了您如何制作视图尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在v0.5-rc0上的一个简单示例可以很好地说明这一点:
This is best illustrated by a simple example on v0.5-rc0:
julia> view(zeros(4,2),:,2)
4-element SubArray{Float64,1,Array{Float64,2},Tuple{Colon,Int64},true}:
0.0
0.0
0.0
0.0
julia> zeros(4,2)[:,2]
4-element Array{Float64,1}:
0.0
0.0
0.0
0.0
第一个返回只有一个列的Array{Float64,2}
的子数组,但是v0.5删除尺寸.有没有办法使SubArray/View删除未使用的尺寸?
The first returns a SubArray of Array{Float64,2}
with only 1 column, but v0.5 drops dimensions. Is there a way to make the SubArray/View drop the unused dimension?
推荐答案
正如Tasos所述,它是 和Array{Float64, 2}
的视图,但是视图本身已经是一维的.实际上,
As Tasos mentioned, it's a view of an Array{Float64, 2}
, but the view itself is one-dimensional already. In fact,
julia> T = SubArray{Float64,1,Array{Float64,2},Tuple{Colon,Int64},true};
julia> T <: AbstractVector{Float64}
true
这篇关于您如何制作视图尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文