<p dir="auto">SubArrays are not subtypes of DenseArray, even when they could be:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; arr = rand(3,3)
3x3 Array{Float64,2}:
 0.838499  0.649594  0.810356
 0.865377  0.204888  0.224049
 0.842879  0.747802  0.67063

julia&gt; s_arr = sub(arr, :, 1)
3-element SubArray{Float64,1,Array{Float64,2},Tuple{Colon,Int64},2}:
 0.838499
 0.865377
 0.842879

julia&gt; super(typeof(s_arr))
AbstractArray{Float64,1}"><pre class="notranslate">julia<span class="pl-k">&gt;</span> arr <span class="pl-k">=</span> <span class="pl-c1">rand</span>(<span class="pl-c1">3</span>,<span class="pl-c1">3</span>)
<span class="pl-c1">3</span>x3 Array{Float64,<span class="pl-c1">2</span>}<span class="pl-k">:</span>
 <span class="pl-c1">0.838499</span>  <span class="pl-c1">0.649594</span>  <span class="pl-c1">0.810356</span>
 <span class="pl-c1">0.865377</span>  <span class="pl-c1">0.204888</span>  <span class="pl-c1">0.224049</span>
 <span class="pl-c1">0.842879</span>  <span class="pl-c1">0.747802</span>  <span class="pl-c1">0.67063</span>

julia<span class="pl-k">&gt;</span> s_arr <span class="pl-k">=</span> <span class="pl-c1">sub</span>(arr, :, <span class="pl-c1">1</span>)
<span class="pl-c1">3</span><span class="pl-k">-</span>element SubArray{Float64,<span class="pl-c1">1</span>,Array{Float64,<span class="pl-c1">2</span>},Tuple{Colon,Int64},<span class="pl-c1">2</span>}<span class="pl-k">:</span>
 <span class="pl-c1">0.838499</span>
 <span class="pl-c1">0.865377</span>
 <span class="pl-c1">0.842879</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">super</span>(<span class="pl-c1">typeof</span>(s_arr))
AbstractArray{Float64,<span class="pl-c1">1</span>}</pre></div>
<p dir="auto">This is a problem when trying to pass the SubArray to a function that only accepts DenseArrays.</p>
<p dir="auto">Many C libraries have functions like the following:</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="void fastadd(size_t len, const double *a, const double *b, double *c)"><pre class="notranslate"><span class="pl-k">void</span> <span class="pl-en">fastadd</span>(<span class="pl-c1">size_t</span> len, <span class="pl-k">const</span> <span class="pl-k">double</span> *a, <span class="pl-k">const</span> <span class="pl-k">double</span> *b, <span class="pl-k">double</span> *c)</pre></div>
<p dir="auto">These functions assume that the arrays have contiguous memory layout.</p>
<p dir="auto">Now for safety, packages like <code class="notranslate">Yeppp</code> and <code class="notranslate">VML</code> etc restrict the arguments to <code class="notranslate">Array</code>. It would be very useful to generalize the fast computation functions there to arbitrary array types with contiguous array layouts (e.g. some <code class="notranslate">SubArray</code> or array views).</p>
<p dir="auto">A <code class="notranslate">iscontiguous</code> function can be useful in such cases</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function fastadd(a::StridedArray{Float64}, b::StridedArray{Float64}, c::StridedArray{Float64})
    (iscontiguous(a) &amp;&amp; iscontiguous(b) &amp;&amp; iscontiguous(c)) || 
        error(&quot;a, b, c must be contiguous&quot;)
    # invoke the fastadd c-function
end"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">fastadd</span>(a<span class="pl-k">::</span><span class="pl-c1">StridedArray{Float64}</span>, b<span class="pl-k">::</span><span class="pl-c1">StridedArray{Float64}</span>, c<span class="pl-k">::</span><span class="pl-c1">StridedArray{Float64}</span>)
    (<span class="pl-c1">iscontiguous</span>(a) <span class="pl-k">&amp;&amp;</span> <span class="pl-c1">iscontiguous</span>(b) <span class="pl-k">&amp;&amp;</span> <span class="pl-c1">iscontiguous</span>(c)) <span class="pl-k">||</span> 
        <span class="pl-c1">error</span>(<span class="pl-s"><span class="pl-pds">"</span>a, b, c must be contiguous<span class="pl-pds">"</span></span>)
    <span class="pl-c"><span class="pl-c">#</span> invoke the fastadd c-function</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">cc: <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/timholy/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/timholy">@timholy</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ViralBShah/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ViralBShah">@ViralBShah</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/simonster/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/simonster">@simonster</a></p>