Hi Samuel, The functionality is very nice but the syntax proposed is maybe a bit complicated? It would be easier to combine ‘newSizes’ with a new ‘shift’ argument (but with no wrapping as proposed in circshift). For example:
m = 2. 5. 9. 3. 2. 4. 5. 5. 4. 1. 8. 5. resize_matrix(m, newSizes=[5 7], shift=[1 2]) ans = 0. 0. 0. 0. 0. 0. 0. 0. 0. 2. 5. 9. 3. 0. 0. 0. 2. 4. 5. 5. 0. 0. 0. 4. 1. 8. 5. 0. 0. 0. 0. 0. 0. 0. 0. resize_matrix(m, newSizes=[-1 -1], shift=[-1 -2]) ans = 5. 5. 0. 0. 8. 5. 0. 0. 0. 0. 0. 0. Regarding extending circshift() to non-integers I had in mind n-dimensional matrices and the discrete Fourier transform. These matrices could represent regularly sampled 1D time signals, or 2D/3D spatial functions, etc. In this context the shift theorem gives a specific meaning to the circular shifts of the input signals (corresponding to linear phase shifts in their spectrum). Regards, Rafael From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Samuel Gougeon Sent: Tuesday, January 09, 2018 8:26 PM To: Users mailing list for Scilab <users@lists.scilab.org> Subject: Re: [Scilab-users] circshift() : Scilab Enhancement Proposal Hello Rafael, To go on about resize_matrix() , padding, and shifting without wrapping: Specifying a (N>1 x 2) matrix of positive (pad) or negative (trim) margins resizing would be simple. Padding with other default elements for non-numerical arrays, or with a chosen value, is already enabled. Possible new syntaxes and examples of usages: resMat = resize_matrix(mat, frameWidth) resMat = resize_matrix(mat, frameWidth, ..) m = [ 6 -7 -1 -2 -6 0 -2 -5 -5 4 -1 8 ]; // shift without extension nor wrapping: resize_matrix(m, [0 0 ; -1 1]) ans = -7 -1 -2 0 0 -2 -5 0 4 -1 8 0 // Another case without extensions nor wrapping: resize_matrix(m, [1 -1 ; 2 -2]) ans = 0 0 0 0 0 0 6 -7 0 0 -6 0 // More general resize_matrix(m, [2 1 ; 1 -1]) ans = 0 0 0 0 0 0 0 0 0 6 -7 -1 0 -6 0 -2 0 -5 4 -1 0 0 0 0 Is it the kind of features you were thinking about? IMO, there is no need to implement this in another specific function, because these features are just particular cases or resizing, with a simple syntax allowing to crop borders as well. Best regards Samuel
_______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users