MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question about matrix operations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42381] Re: [mg42366] Question about matrix operations
  • From: Ken Levasseur <klevasseur at mac.com>
  • Date: Thu, 3 Jul 2003 06:10:35 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Jeff:

A while ago I wrote up code to identify a basis for the column space of a
matrix using RowReduce.  Here it is.  FirstOne is simply a function that
identifies the first position of a 1.   I'm sure that this could be improved
upon.

As for the span, describing as simply the span of the basis is one option.
A function to test whether a vector is in the span shouldn't be difficult.
You could compare the Rank of A with the rank of [A|b], for column space.

In[1]:=
FirstOne[row_] := If[MemberQ[row, 1],
   First[Flatten[Position[row, 1]]], 0]

In[2]:=
ColumnBasis[A_] := Transpose[Transpose[A][[
    FirstOne /@ RowReduce[A] /. {{p___, 0, q___} -> {p}}]]]

In[3]:=
A = {{0, 0, 0, -1, 0}, {1, -1, -1, 1, 0}, {1, -1, -1, 1, 0}, {-1, 1, 0, 1,
1}}

Out[3]=
{{0, 0, 0, -1, 0}, {1, -1, -1, 1, 0}, {1, -1, -1, 1, 0},
 
  {-1, 1, 0, 1, 1}}

In[4]:=
ColumnBasis[A]

Out[4]=
{{0, 0, -1}, {1, -1, 1}, {1, -1, 1}, {-1, 0, 1}}


Ken Levasseur
Math. Sci.
UMass Lowell

> From: Jeff Borski <jmborski at yahoo.com>
To: mathgroup at smc.vnet.net
> Date: Wed, 02 Jul 2003 06:36:28 -0400 (EDT)
> To: mathgroup at smc.vnet.net
> Subject: [mg42381] [mg42366] Question about matrix operations
> 
> Do you know of any way to find the basis and span of a group of vectors
> using Mathematica?
> 
> Thanks:)
> 
> Jeff Borski
> 
> 
> 


  • Prev by Date: Re: How to get Mathematica to solve for "nonbasic variables"?
  • Next by Date: Re: New version, new bugs
  • Previous by thread: Re: Question about matrix operations
  • Next by thread: How to get Mathematica to solve for "nonbasic variables"?