Dear Max,

Thank you very much for your help. I will try again.

With best wishes,
Jianrong.


> -----原始邮件-----
> 发件人: "Max Horn" <m...@quendi.de>
> 发送时间: 2013年1月7日 星期一
> 收件人: "李建荣" <l...@lzu.edu.cn>
> 抄送: 
> 主题: [SPAM] Re: [GAP Forum] Coefficients in GAP
> 
> Dear Jianrong,
> 
> 
> On 06.01.2013, at 14:52, 李建荣 wrote:
> 
> > Dear Forum,
> > 
> > I would like to compute coefficients of a vector in a vector space V with 
> > respect to some basis B.
> > The command in GAP is Coefficients(B, v); 
> > 
> > If B is given by a list, then it seems that it doesn't work.
> 
> Indeed, because as the documentation of Coefficients states, B must be a 
> basis -- and a "basis" here is a special GAP object, which is more than just 
> a list of basis vectors.
> 
> One of the reasons for this is that for an arbitrary list of vectors, such as 
> yours, it is not at all clear whether it actually forms a basis of the space 
> spanned by those vectors, i.e. if they are linearly independent.
> 
> 
> > For example, Coefficients([Basis(B)[1], Basis(B)[2], Basis(B)[3], 
> > Basis(B)[4], Basis(B)[5], Basis(B)[6], Basis(B)[7], Basis(B)[8], 
> > Basis(B)[9], Basis(A)[2]], Basis(B)[4]*Basis(A)[3]) will have errors. Here 
> > B is a subspace of the vector space A. A consists of matrices. The codes 
> > are in the end of the email. How should I correct  
> > Coefficients([Basis(B)[1], Basis(B)[2], Basis(B)[3], Basis(B)[4], 
> > Basis(B)[5], Basis(B)[6], Basis(B)[7], Basis(B)[8], Basis(B)[9], 
> > Basis(A)[2]], Basis(B)[4]*Basis(A)[3])? Thank you very much.
> 
> This look as if you want to form a new basis by taking a subset of the 
> existing Basis(B). Here is a sketch of how this could look like.
> 
> # Set F to your base field, e.g. GF(3^2)
> F := ...;
> 
> # Take first 9 basis vectors of B plus second basis vector of A
> vecs := Concatenation( Basis(B){[1..9]}, Basis(A){[2]} );
> 
> # Compute a basis of the spanned vector space:
> bas := ImmutableBasis( MutableBasis( F, vecs ) );
> 
> # Optionally, check whether "vecs" really formed a basis.
> if Length(vecs) <> Length(bas) then
>   Error("vectors do not form a basis"
> fi;
> 
> # Finally, attempt to rewrite a matrix using this basis
> Coefficients( bas, Basis(B)[4]*Basis(A)[3] )
> 
> 
> But looking at your example code, and considering your previous question, it 
> seems that perhaps all you want to do is to check whether some vector is 
> contained in the span of some other vectors. Moreover, your code seems to 
> contain a mistake (it sets number:=1 inside the loop over k, but tests it 
> only after that loop; hence, only the result of the last loop iteration has 
> any effect). Supposing all this, you could try something like the following 
> (here I assumed you wanted to set and test "number" outside the k-loop; if 
> the correct thing for you problem is to check "number" on each iteration of 
> that loop, of course you'll have to move things around accordingly):
> 
> for i in complement do
>   vecs := Concatenation( Basis(B){[1..9]}, Basis(A){[i]} );
>   sub := VectorSpace( F, vecs );
>   number := true;
>   for k in [1..9] do
>     for l in vecs do
>       if not Basis(B)[k] * l in sub then
>         number:=false;
>       fi;
>     od;
>   od;
>   if number=true then Add(new_indices_in_LminusOne, i); fi;
> od;
> 
> 
> The code can actually be simplified a lot more, e.g. by using ForAny or 
> ForAll; and more so if, for example, your space B is actually 9-dimensional. 
> 
> 
> Hope that helps,
> Max
> 
> 
> > 
> > With best wishes,
> > Jianrong.
> > 
> > 
> > 
> > for i in complement do
> > for k in [1..9] do
> > number:=1;
> > for l in [Basis(B)[1], Basis(B)[2], Basis(B)[3], Basis(B)[4], Basis(B)[5], 
> > Basis(B)[6], Basis(B)[7], Basis(B)[8], Basis(B)[9], Basis(A)[i]] do
> > if Coefficients([Basis(B)[1], Basis(B)[2], Basis(B)[3], Basis(B)[4], 
> > Basis(B)[5], Basis(B)[6], Basis(B)[7], Basis(B)[8], Basis(B)[9], 
> > Basis(A)[i]], Basis(B)[k]*l)=fail then number:=0; fi;
> > od;
> > od;
> > if number=1 then Add(new_indices_in_LminusOne, i); fi;
> > od;
> > 
> > _______________________________________________
> > Forum mailing list
> > Forum@mail.gap-system.org
> > http://mail.gap-system.org/mailman/listinfo/forum
> > 
> 


_______________________________________________
Forum mailing list
Forum@mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to