This should work for the three cases you have set up:

f_scaleRestore(a, b, c) = a .* b' .+ c'


On Friday, October 14, 2016 at 9:12:55 AM UTC+2, Martin Florek wrote:
>
> Hi all,
>
> I have the following two functions and I want to sensibly merge them into 
> one. How to marge headers and body of function for Matrix and Vector?
> - 
> f_scaleRestore(a::Float64, b::Float64, c::Float64) = a * b + c;
> -  
> - # version 1
> - function scaleRestore(Z::Matrix{Float64}, shift::Vector{Float64}, 
> stretch::Vector{Float64})
> -   broadcast(f_scaleRestore, Z, stretch', shift')
> - end
> -  
> - # version 2
> - function scaleRestore(Z::Vector{Float64}, shift::Float64, stretch::
> Float64)
> -   broadcast(f_scaleRestore, Z, stretch, shift)
> - end
>
>
> Thanks in advance,
> Martin
>

Reply via email to