Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Finding Linearly dependent rows/columns

Subject: Finding Linearly dependent rows/columns

From: Ali

Date: 11 Oct, 2007 13:37:56

Message: 1 of 12

Hi!

Inverse of a m x n matrix A when matrix is rank deficient
and I can be find it using rank(A). However, I don't know
how to find which rows/columns of the matrix are linearly
dependent. I m sure there must be a way to find this. Can
any body help me with this?

Thanks,

Ali

Subject: Finding Linearly dependent rows/columns

From: Rune Allnor

Date: 11 Oct, 2007 14:43:07

Message: 2 of 12

On 11 Okt, 15:37, "Ali " <muhammad....@tut.fi> wrote:
> Hi!
>
> Inverse of a m x n matrix A when matrix is rank deficient
> and I can be find it using rank(A). However, I don't know
> how to find which rows/columns of the matrix are linearly
> dependent.

Both the QR decomposition and Singular Value Decomposition
come to mind?

Rune

Subject: Finding Linearly dependent rows/columns

From: John D'Errico

Date: 11 Oct, 2007 15:08:37

Message: 3 of 12

"Ali " <muhammad.ali@tut.fi> wrote in message <fel8vk$qmj
$1@fred.mathworks.com>...
> Hi!
>
> Inverse of a m x n matrix A when matrix is rank deficient
> and I can be find it using rank(A). However, I don't know
> how to find which rows/columns of the matrix are linearly
> dependent. I m sure there must be a way to find this. Can
> any body help me with this?

A = randn(9,10);
B = A'*A;

rank(B) == 9

Which columns of B are dependent?

Answer: all of them. Any column can be written as a
linear combination of the rest.

John

Subject: Finding Linearly dependent rows/columns

From: Justin Abbott

Date: 11 Oct, 2007 17:41:13

Message: 4 of 12

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fele9k$ltf$1@fred.mathworks.com>...
> "Ali " <muhammad.ali@tut.fi> wrote in message <fel8vk$qmj
> $1@fred.mathworks.com>...
> > Hi!
> >
> > Inverse of a m x n matrix A when matrix is rank
deficient
> > and I can be find it using rank(A). However, I don't
know
> > how to find which rows/columns of the matrix are
linearly
> > dependent. I m sure there must be a way to find this.
Can
> > any body help me with this?
>
> A = randn(9,10);
> B = A'*A;
>
> rank(B) == 9
>
> Which columns of B are dependent?
>
> Answer: all of them. Any column can be written as a
> linear combination of the rest.
>
> John
>

John --

I am not sure I understand the entire meaning of your
post. What about an example like this?

A = eye(9);
B = [A(:,1) A];

rank(B) == 9

However it is not true that any column in B is a linear
combination of the rest, e.g. B(:,10) is linearly
independent of the first 9.

-Justin

Subject: Finding Linearly dependent rows/columns

From: John D'Errico

Date: 11 Oct, 2007 19:03:01

Message: 5 of 12

"Justin Abbott" <jjabbott.NOSPAM@gmail.com> wrote in message <feln7p
$rap$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <fele9k$ltf$1@fred.mathworks.com>...
> > "Ali " <muhammad.ali@tut.fi> wrote in message <fel8vk$qmj
> > $1@fred.mathworks.com>...
> > > Hi!
> > >
> > > Inverse of a m x n matrix A when matrix is rank
> deficient
> > > and I can be find it using rank(A). However, I don't
> know
> > > how to find which rows/columns of the matrix are
> linearly
> > > dependent. I m sure there must be a way to find this.
> Can
> > > any body help me with this?
> >
> > A = randn(9,10);
> > B = A'*A;
> >
> > rank(B) == 9
> >
> > Which columns of B are dependent?
> >
> > Answer: all of them. Any column can be written as a
> > linear combination of the rest.
> >
> > John
> >
>
> John --
>
> I am not sure I understand the entire meaning of your
> post. What about an example like this?
>
> A = eye(9);
> B = [A(:,1) A];
>
> rank(B) == 9
>
> However it is not true that any column in B is a linear
> combination of the rest, e.g. B(:,10) is linearly
> independent of the first 9.
>
> -Justin

Yes, but of the columns of B, which ONE is dependent?
Is it column 1 or column 2? I had the impression that
you were looking for a single column which is dependent
on the rest, at least from your original question.

All that you can do in general is list a group of columns
which when taken together form a dependent set.

If you wish to find those subsets of columns which are
dependent, then form

  C = B'*B

if you can now symmetricaly permute the rows and
columns of C, such that it is block diagonal, with
zeros in the off diagonal blocks, then each block
represents one such dependent set of vectors.

A = eye(4);
B = [A(:,1)+2*A(:,4) A];

C = B'*B

C =
     5 1 0 0 2
     1 1 0 0 0
     0 0 1 0 0
     0 0 0 1 0
     2 0 0 0 1

p = symamd(C)
p =
     2 1 5 3 4

C(p,p)
ans =
     1 1 0 0 0
     1 5 2 0 0
     0 2 1 0 0
     0 0 0 1 0
     0 0 0 0 1

John

Subject: Finding Linearly dependent rows/columns

From: John D'Errico

Date: 11 Oct, 2007 19:03:01

Message: 6 of 12

"Justin Abbott" <jjabbott.NOSPAM@gmail.com> wrote in message <feln7p
$rap$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <fele9k$ltf$1@fred.mathworks.com>...
> > "Ali " <muhammad.ali@tut.fi> wrote in message <fel8vk$qmj
> > $1@fred.mathworks.com>...
> > > Hi!
> > >
> > > Inverse of a m x n matrix A when matrix is rank
> deficient
> > > and I can be find it using rank(A). However, I don't
> know
> > > how to find which rows/columns of the matrix are
> linearly
> > > dependent. I m sure there must be a way to find this.
> Can
> > > any body help me with this?
> >
> > A = randn(9,10);
> > B = A'*A;
> >
> > rank(B) == 9
> >
> > Which columns of B are dependent?
> >
> > Answer: all of them. Any column can be written as a
> > linear combination of the rest.
> >
> > John
> >
>
> John --
>
> I am not sure I understand the entire meaning of your
> post. What about an example like this?
>
> A = eye(9);
> B = [A(:,1) A];
>
> rank(B) == 9
>
> However it is not true that any column in B is a linear
> combination of the rest, e.g. B(:,10) is linearly
> independent of the first 9.
>
> -Justin

Yes, but of the columns of B, which ONE is dependent?
Is it column 1 or column 2? I had the impression that
you were looking for a single column which is dependent
on the rest, at least from your original question.

All that you can do in general is list a group of columns
which when taken together form a dependent set.

If you wish to find those subsets of columns which are
dependent, then form

  C = B'*B

if you can now symmetricaly permute the rows and
columns of C, such that it is block diagonal, with
zeros in the off diagonal blocks, then each block
represents one such dependent set of vectors.

A = eye(4);
B = [A(:,1)+2*A(:,4) A];

C = B'*B

C =
     5 1 0 0 2
     1 1 0 0 0
     0 0 1 0 0
     0 0 0 1 0
     2 0 0 0 1

p = symamd(C)
p =
     2 1 5 3 4

C(p,p)
ans =
     1 1 0 0 0
     1 5 2 0 0
     0 2 1 0 0
     0 0 0 1 0
     0 0 0 0 1

John

Subject: Finding Linearly dependent rows/columns

From: John D'Errico

Date: 11 Oct, 2007 19:03:01

Message: 7 of 12

"Justin Abbott" <jjabbott.NOSPAM@gmail.com> wrote in message <feln7p
$rap$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <fele9k$ltf$1@fred.mathworks.com>...
> > "Ali " <muhammad.ali@tut.fi> wrote in message <fel8vk$qmj
> > $1@fred.mathworks.com>...
> > > Hi!
> > >
> > > Inverse of a m x n matrix A when matrix is rank
> deficient
> > > and I can be find it using rank(A). However, I don't
> know
> > > how to find which rows/columns of the matrix are
> linearly
> > > dependent. I m sure there must be a way to find this.
> Can
> > > any body help me with this?
> >
> > A = randn(9,10);
> > B = A'*A;
> >
> > rank(B) == 9
> >
> > Which columns of B are dependent?
> >
> > Answer: all of them. Any column can be written as a
> > linear combination of the rest.
> >
> > John
> >
>
> John --
>
> I am not sure I understand the entire meaning of your
> post. What about an example like this?
>
> A = eye(9);
> B = [A(:,1) A];
>
> rank(B) == 9
>
> However it is not true that any column in B is a linear
> combination of the rest, e.g. B(:,10) is linearly
> independent of the first 9.
>
> -Justin

Yes, but of the columns of B, which ONE is dependent?
Is it column 1 or column 2? I had the impression that
you were looking for a single column which is dependent
on the rest, at least from your original question.

All that you can do in general is list a group of columns
which when taken together form a dependent set.

If you wish to find those subsets of columns which are
dependent, then form

  C = B'*B

if you can now symmetricaly permute the rows and
columns of C, such that it is block diagonal, with
zeros in the off diagonal blocks, then each block
represents one such dependent set of vectors.

A = eye(4);
B = [A(:,1)+2*A(:,4) A];

C = B'*B

C =
     5 1 0 0 2
     1 1 0 0 0
     0 0 1 0 0
     0 0 0 1 0
     2 0 0 0 1

p = symamd(C)
p =
     2 1 5 3 4

C(p,p)
ans =
     1 1 0 0 0
     1 5 2 0 0
     0 2 1 0 0
     0 0 0 1 0
     0 0 0 0 1

John

Subject: Finding Linearly dependent rows/columns

From: Ali

Date: 12 Oct, 2007 09:21:56

Message: 8 of 12

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fels15$o47$1@fred.mathworks.com>...
> "Justin Abbott" <jjabbott.NOSPAM@gmail.com> wrote in
message <feln7p
> $rap$1@fred.mathworks.com>...
> > "John D'Errico" <woodchips@rochester.rr.com> wrote in
> > message <fele9k$ltf$1@fred.mathworks.com>...
> > > "Ali " <muhammad.ali@tut.fi> wrote in message
<fel8vk$qmj
> > > $1@fred.mathworks.com>...
> > > > Hi!
> > > >
> > > > Inverse of a m x n matrix A when matrix is rank
> > deficient
> > > > and I can be find it using rank(A). However, I
don't
> > know
> > > > how to find which rows/columns of the matrix are
> > linearly
> > > > dependent. I m sure there must be a way to find
this.
> > Can
> > > > any body help me with this?
> > >
> > > A = randn(9,10);
> > > B = A'*A;
> > >
> > > rank(B) == 9
> > >
> > > Which columns of B are dependent?
> > >
> > > Answer: all of them. Any column can be written as a
> > > linear combination of the rest.
> > >
> > > John
> > >
> >
> > John --
> >
> > I am not sure I understand the entire meaning of your
> > post. What about an example like this?
> >
> > A = eye(9);
> > B = [A(:,1) A];
> >
> > rank(B) == 9
> >
> > However it is not true that any column in B is a linear
> > combination of the rest, e.g. B(:,10) is linearly
> > independent of the first 9.
> >
> > -Justin
>
> Yes, but of the columns of B, which ONE is dependent?
> Is it column 1 or column 2? I had the impression that
> you were looking for a single column which is dependent
> on the rest, at least from your original question.
>
> All that you can do in general is list a group of columns
> which when taken together form a dependent set.
>
> If you wish to find those subsets of columns which are
> dependent, then form
>
> C = B'*B
>
> if you can now symmetricaly permute the rows and
> columns of C, such that it is block diagonal, with
> zeros in the off diagonal blocks, then each block
> represents one such dependent set of vectors.
>
> A = eye(4);
> B = [A(:,1)+2*A(:,4) A];
>
> C = B'*B
>
> C =
> 5 1 0 0 2
> 1 1 0 0 0
> 0 0 1 0 0
> 0 0 0 1 0
> 2 0 0 0 1
>
> p = symamd(C)
> p =
> 2 1 5 3 4
>
> C(p,p)
> ans =
> 1 1 0 0 0
> 1 5 2 0 0
> 0 2 1 0 0
> 0 0 0 1 0
> 0 0 0 0 1
>
> John

Hi!

I do not understand your solution and what I can get out of
there. I want to know is there a way to get the index
number of the rows which are linearly dependent or
conversely the index of rows which are linearly
independent. In that way I can seperate those rows and
proceed with the inverse of rest of the augumented matrix.

Thanks,

Ali

Subject: Finding Linearly dependent rows/columns

From: Steven Lord

Date: 12 Oct, 2007 13:30:16

Message: 9 of 12


"Ali " <muhammad.ali@tut.fi> wrote in message
news:fenebk$ici$1@ginger.mathworks.com...

*snip*

> I do not understand your solution and what I can get out of
> there. I want to know is there a way to get the index
> number of the rows which are linearly dependent or
> conversely the index of rows which are linearly
> independent. In that way I can seperate those rows and
> proceed with the inverse of rest of the augumented matrix.

Don't split apart the matrix like this just to invert a submatrix that is of
full rank. Don't invert a matrix unless you ABSOLUTELY, POSITIVELY have to
do so. If you're trying to invert the matrix to solve a system of
equations, use backslash (\) instead.

--
Steve Lord
slord@mathworks.com


Subject: Finding Linearly dependent rows/columns

From: Greg Heath

Date: 16 Oct, 2007 12:35:07

Message: 10 of 12

On Oct 15, 2:11 pm, "Tim Davis" <da...@cise.ufl.edu> wrote:
> Greg Heath <he...@alumni.brown.edu> wrote in message
> ...
>
>
>
>
>
> > Furthermore, when A is rank deficient, the BACKSLASH
> > solution will be a "BASIC" solution that contains zero
> > coefficients corresponding to variables that could be
> > considered to be "the most dependent". However, the
> > selection is completely based on partial pivoting
> > strategy using the QR algorithm and may not have a
> > corresponding causal or scientific explanation.
> > It may be helpful to search the CSSM archives in
> > Google groups with
>
> > greg-heath basic solution
>
> > The groups of dependent variables can be deduced from
> > the components of the null singular vector solutions
> > to A*x = 0.
>
> > Hope this helps.
>
> > Greg
>
> Does this apply just when backslash uses a dense QR
> factorization? Or does the sparse QR as used by backslash
> also give a basic solution when A is rank deficient? Sparse
> QR doesn't do any column pivoting, so A\b for sparse
> rectangular rank deficient A doesn't either (well, it does
> do column pivoting for sparsity, but not for numerical
> reasons, which is the issue here).

I don't know.

If someone else doesn't reply with an answer,
try a simple test case.

Hope this helps.

Greg


Subject: Finding Linearly dependent rows/columns

From: Paula Olave

Date: 3 Nov, 2007 03:49:09

Message: 11 of 12

"Ali " <muhammad.ali@tut.fi> wrote in message
<fel8vk$qmj$1@fred.mathworks.com>...
> Hi!
>
> Inverse of a m x n matrix A when matrix is rank deficient
> and I can be find it using rank(A). However, I don't know
> how to find which rows/columns of the matrix are linearly
> dependent. I m sure there must be a way to find this. Can
> any body help me with this?
>
> Thanks,
>
> Ali

I found which are linearly dependent rows.

I modify the rref function

function [A,jb,b] = rrefs(A,tol)

% Copyright 1984-2004 The MathWorks, Inc.
% $Revision: 5.9.4.2 $ $Date: 2004/04/10 23:30:09 $

b is the new out
  
[m,n] = size(A);
b=1:m;
% Does it appear that elements of A are ratios of small
integers?
[num, den] = rat(A);
rats = isequal(A,num./den);

% Compute the default tolerance if none was provided.
if (nargin < 2), tol = max(m,n)*eps(class(A))*norm(A,'inf'); end

% Loop over the entire matrix.
i = 1;
j = 1;
jb = [];
xb=[];
while (i <= m) && (j <= n)
   % Find value and index of largest element in the
remainder of column j.
   [p,k] = max(abs(A(i:m,j)));
   k = k+i-1;
   if (p <= tol)
      % The column is negligible, zero it out.
      A(i:m,j) = zeros(m-i+1,1);
      j = j + 1;
   else
      % Remember column index
      jb = [jb j];
     
      % Swap i-th and k-th rows.
      
      >>>>>>b([i k])=b([k i]);<<<<<<< The modification
      A([i k],j:n) = A([k i],j:n);
      % Divide the pivot row by the pivot element.
      A(i,j:n) = A(i,j:n)/A(i,j);
      % Subtract multiples of the pivot row from all the
other rows.
     
      for k = [1:i-1 i+1:m]
         A(k,j:n) = A(k,j:n) - A(k,j)*A(i,j:n);
      end
      i = i + 1;
      j = j + 1;
   end
end

% Return "rational" numbers if appropriate.
if rats
    [num,den] = rat(A);
    A=num./den;
end


if c=rank(A)<m

the linearly dependent rows are b(c+1:m)

I hope that this help you

Subject: Finding Linearly dependent rows/columns

From: Dan Wunderli

Date: 14 May, 2008 16:26:55

Message: 12 of 12

Thanks Paula, you're an Angel!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
linearly dependent rows Paula Olave 2 Nov, 2007 23:50:25
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics