Hi Carl,
Are you possibly referring to the Kronecker (tensor) product
(http://en.wikipedia.org/wiki/Kronecker_product)? For two vectors
(length m and n), the Kronecker product gives a matrix (size m x n)
whose elements are all the combinations of products of the components of
the original vectors.
-Travis-
Dennis Shea wrote:
> Carl J. Schreck, III wrote:
>> Is there a built-in way to do a cross product in ncl? For example, if
>> you have an array of length m and another of length n, it would return
>> a matrix that's m x n? I see dot products mentioned in the
>> documentation for matrix multiply (#), but no cross product.
>>
> I guess I don't see exactly what you mean.
> Are not cross products only defined in 3D space?
> I have a cross product function but it is pretty simple.
>
>
> function cross_prod(a[*][3]:numeric, b[*][3]:numeric)
> ; calculate a cross product: c = a x b
> begin
> c = new ( dimsizes(a), typeof(a), "No_FillValue")
>
> c(:,0) = a(:,1)*b(:,2)-a(:,2)*b(:,1)
> c(:,1) = a(:,2)*b(:,0)-a(:,0)*b(:,2)
> c(:,3) = a(:,0)*b(:,1)-a(:,1)*b(:,0)
>
> return(c)
> end
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- Travis A. O'Brien Graduate Student Researcher Earth and Planetary Science Dept. UC Santa Cruz tobrien_at_ucsc.edu (831) 459-3504 _______________________________________________ ncl-talk mailing list ncl-talk_at_ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Sep 10 2008 - 16:57:24 MDT
This archive was generated by hypermail 2.2.0 : Fri Sep 12 2008 - 21:42:04 MDT