Question: is there a member() function for Vectors ?

Hi there,

 I have a piece of code that uses lists instead of vectors and recently, it crashed, it ran out of memory. Long story short, if I use vectors instead of lists, the performance is much better and optimal (this I knew but I was lazy to translate all my code). However, there's one single line that I cannot efficiently translate and it's the one that uses the function member(). Before, I had the following (it's an oversimplification of my code in order to easily discuss it in here):

 

>basis:=[[4,0,0,0],[3,2,0,0],[2,0,0,2],[1,1,2,0]]:

>v:=[2,0,0,2]:

>member(v,basis,index):

 

Where the basis list in my code is actually very long(up to 7,000 inner lists). After the translation to vectors, the code looks something like this:

 

>basis:=Vector(1..4):

>basis[1]:=Vector([4,0,0,0]): basis[2]:=Vector([3,2,0,0]): basis[3]:=Vector([2,0,0,2]): basis[4]:=Vector([1,1,2,0]):

>v:=Vector([2,0,0,2]):

 

The problem now is that I cannot use member(v,basis,index) any longer.

Do you guys know any work around this problem ? Having a unique way to index the vectors in the basis would also solve my problem (perhaps more optimally?) but I don't know how to do it yet(the number of elements of the inner lists is around 45 so trivial indexing is not a good option).

 

Cheers.

Please Wait...