# Reshape of subarray

**URL:** <https://discourse.julialang.org/t/reshape-of-subarray/4920>\
**Category:** General Usage\
**Created:** [July 18, 2017, 10:48am UTC](https://discourse.julialang.org/t/reshape-of-subarray/4920 "2017-07-18T10:48:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [July 18, 2017, 10:48am UTC](https://discourse.julialang.org/t/reshape-of-subarray/4920/1 "2017-07-18T10:48:08Z")

</div>

```julia
A = randn(10,2)
svd(reshape(view(A,1:10), (5,2)))

```

yields a MethodError. Is it a fault in the way svd is defined, or just me doing something wrong/“unjulian”? What’s the correct way to do this without copy?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [July 19, 2017, 12:25pm UTC](https://discourse.julialang.org/t/reshape-of-subarray/4920/2 "2017-07-19T12:25:30Z")

</div>

The main issue is that we don’t seem to have a generic implementation of `svdfact`, because we rely on LAPACK. Unless you want to write one in pure Julia, best would be to have a fallback. If you don’t want to submit as a PR to julia, then please do file an issue.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [July 19, 2017, 3:26pm UTC](https://discourse.julialang.org/t/reshape-of-subarray/4920/3 "2017-07-19T15:26:11Z")

</div>

This case is slightly different because `reshape(view(A,1:10), (5,2))` _is_ a contiguous (strided) array that LAPACK could support. I believe it should be fixed by [https://github.com/JuliaLang/julia/pull/22429](https://github.com/JuliaLang/julia/pull/22429), which is pending backports.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 19, 2017, 4:34pm UTC](https://discourse.julialang.org/t/reshape-of-subarray/4920/4 "2017-07-19T16:34:45Z")

</div>

> [@tim.holy](#):
>
> The main issue is that we don’t seem to have a generic implementation of svdfact, because we rely on LAPACK. Unless you want to write one in pure Julia, best would be to have a fallback. If you don’t want to submit as a PR to julia, then please do file an issue.

> **[GitHub - JuliaLinearAlgebra/GenericSVD.jl: Singular Value Decomposition for...](https://github.com/JuliaLinearAlgebra/GenericSVD.jl)**
>
> Singular Value Decomposition for generic number types - GitHub - JuliaLinearAlgebra/GenericSVD.jl: Singular Value Decomposition for generic number types

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [July 19, 2017, 7:02pm UTC](https://discourse.julialang.org/t/reshape-of-subarray/4920/5 "2017-07-19T19:02:20Z")

</div>

@mbauman yes that was the point, sorry I should have made it more clear. The PR looks set to fix it, that’s great!
