As a proposal, this is what I would do, given you requirements:

function _scaleRestore!(Z, Zout, shift, stretch)
    for j in 1:size(Z, 2), i in 1:size(Z, 1)
        Zout[i, j] = Z[i, j] * stretch[j] + shift[j]
    end
    return Zout
end
scaleRestore!(Z::Vector, shift::Number, stretch::Number) = _scaleRestore!(Z, 
Z, shift, stretch)
scaleRestore!(Z::Matrix, shift::Vector, stretch::Vector) = _scaleRestore!(Z, 
Z, shift, stretch)

scaleRestore(Z::Vector, shift::Number, stretch::Number) = _scaleRestore!(Z, 
similar(Z), shift, stretch)
scaleRestore(Z::Matrix, shift::Vector, stretch::Vector) = _scaleRestore!(Z, 
similar(Z), shift, stretch)

I put in both mutating and non-mutating versions, just in case. Single 
signature definition I cannot help you with, I'm afraid.

Reply via email to