>>>>> On Thu, 13 Aug 1998 13:06:21 +0200 (MET DST),

>>>>> Peter Waller <

[hidden email]> said:

> Hi!

> I have a small problem.

> A=randn(10,3);

> B=randn(10,3);

> I want to calculate cross(A,B), ie. cross(A(k,:),B(k,:)), k=1..10

> This does not work with the ordinary cross product. I want to solve this

> problem without loops etc, any sugestion?

> /Peter Waller

I faced the same problem several times. I coded this

================================================================

function c=cross(a,b)

## CROSS returns the cross (vectorial) product of two vectors

## c=pvec(a,b) ==> c = a x b

##

c=zeros(size(a));

c(:,1)=a(:,2).*b(:,3)-a(:,3).*b(:,2);

c(:,2)=a(:,3).*b(:,1)-a(:,1).*b(:,3);

c(:,3)=a(:,1).*b(:,2)-a(:,2).*b(:,1);

endfunction

================================================================

I should add some day a trivial error checking, etc...

Also I had to write a series of functions in order to solve a large

number of small linear systems. For instance, say 10000 systems of

3x3. This arises in finite element analysis in order to avoid loops over

elements or gauss points.

Regards,

Mario