octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subspace


From: John W. Eaton
Subject: Re: subspace
Date: Thu, 20 Mar 2008 09:43:13 -0400

On 20-Mar-2008, Jaroslav Hajek wrote:

| A changeset with the checks attached.

OK, I checked in the slightly modified version below.  I used ndims
becuase the ismatrix function also returns true for arrays with more
than 2 dimensions.

Also, I see this behavior now:

  octave:3> subspace (rand (2), rand (3))
  error: operator *: nonconformant arguments (op1 is 2x2, op2 is 3x3)
  error: caught execution error in library function
  error: evaluating binary operator `*' near line 45, column 9
  error: evaluating assignment expression near line 45, column 5
  error: called from `subspace' in file 
`/home/jwe/src/octave/scripts/linear-algebra/subspace.m'

I think subspace should give a clear diagnostic if the arguments don't
meet its requirements rather than allowing some subsequent operation
to fail and produce an obscure message like this.

| Btw. is attaching changesets as
| files OK, or is it better to include it in the message (as you and Ben
| do)?

Using file attachments is best because it avoids mail system line
wrapping problems.  I prefer text/plain attachments (that's what I
use, so maybe that is why your mailer presents them as if they are in
the message).

jwe


# HG changeset patch
# User Jaroslav Hajek <address@hidden>
# Date 1206020210 14400
# Node ID c1702f963a5e7b8dc3f95a99560c47fc87e0fa80
# Parent  4f903c303c3c1809ad67d8cd4170f3192c3cd74b
error check for subspace.m

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@ 2008-03-19  Jaroslav Hajek  <address@hidden
+2008-03-20  Jaroslav Hajek  <address@hidden>
+
+       * linear-algebra/subspace.m: Check number of arguments and number
+       of dimensions of arguments.
+
 2008-03-19  Jaroslav Hajek  <address@hidden>
 
        * linear-algebra/subspace.m: New function.
diff --git a/scripts/linear-algebra/subspace.m 
b/scripts/linear-algebra/subspace.m
--- a/scripts/linear-algebra/subspace.m
+++ b/scripts/linear-algebra/subspace.m
@@ -34,6 +34,12 @@
 
 function ang = subspace (a, b)
 
+  if (nargin != 2)
+    print_usage ();
+  elseif (ndims (a) != 2 || ndims (b) != 2)
+    error ("subspace: expecting A and B to be 2-dimensional arrays");
+  endif
+
   a = orth (a);
   b = orth (b);
   c = a'*b;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]