(1) The size of arrays isn’t part of their type signature, so you can’t use 
multiple dispatch to do this. You’ll end up overwriting the existing Array 
multiplication function.

(2) You’d want to do something like *{S <: Number, T <: Number}(a::Array{S, 
2},b::Array{T,1}) to indicate that you’re allowing arbitrary types. For your 
use case, you need to use Number because Julia’s Complex type is a concrete 
type, so Real isn’t a subtype of it. In Base Julia, I don’t believe there are 
any types that descend from Number that wouldn’t interact properly with Complex.

 — John

On Jun 24, 2014, at 6:10 AM, Rick Muller <[email protected]> wrote:

> I want to create a function signature for the *(a,b) operator where a is a 
> 2x2 matrix. Can I do this?
> 
>     *(a::Array{??,2},b) = whatever
> 
> ??? is anything than can multiply a Complex vector. Do I have to explicitly 
> promote this to Complex, in which case I guess it would be
> 
>    *(a::Array{Complex,(2,2)},b::Array{Complex,1}) = whatever
> 
> Thanks in advance for any help you can offer.  

Reply via email to