@@ 5,7 5,20 @@
⊃{⊖⍤⍺⊢⍵}⌿rotations,⊂data
}
reshape2←{
- (dims data)←⍺ process ⍵
- dims reshape data
+ (absDims data)←⍺ process ⍵
+ (absDims××⍺) reshape data
+ }
+ process←{
+ absDims←|⍺
+ dataLength←≢,⍵
+ specialMask←∨⌿0.5 1.5 2.5(=⍤0 1)absDims
+ specialDim←specialMask⌿absDims
+ restDims←(~specialMask)⌿absDims
+ upSize←⌈dataLength÷×⌿restDims
+ downSize←⌊dataLength÷×⌿restDims
+ 0=≢specialDim:absDims ⍵ ⍝ no special values in dims
+ 0.5=specialDim: (downSize@(⍸specialMask)⊢absDims) ⍵
+ 1.5=specialDim: (upSize@(⍸specialMask)⊢absDims) ⍵
+ 2.5=specialDim: (upSize@(⍸specialMask)⊢absDims) (⍵↑⍨×⌿upSize,restDims)
}
:EndNamespace