[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Questions from a newcomer...
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 14 May 1999 22:54:48 -0300 (EST)
>From markv@pixar.com Fri May 14 19:31:45 1999
>
>m = matrix{1.0, 0.0, 0.0, 0.0,
> 0.0, 1.0, 0.0, 0.0,
> 0.0, 0.0, 1.0, 0.0,
> 0.0, 0.0, 0.0, 1.0} ;
>
>
>v = vector{10.0, 3.0, 1.0} ;
>
>newvec = m * v ;
>
>Would it be best to make m and v user data objects, and tag them with types, then override the tag methods to check for these types prior to calling the original tag methods?
try something like this:
MATVEC=newtag()
function matrix(t)
settag(t,MATVEC)
t.type="matrix"
return t
end
function vector(t)
settag(t,MATVEC)
t.type="vector"
return t
end
function do_mul(a,b)
-- test a.type and b.type and do the right thing
end
settagmethod(MATVEC, "mul", do_mul)
--lhf