# bug #53690: incorrect test in delaunayn?

 Submitted by: A.R. Burgers Submitted on: Wed 18 Apr 2018 07:38:50 AM UTC Category: Octave Function Severity: 3 - Normal Priority: 5 - Normal Item Group: Incorrect Result Status: Invalid Assigned to: None Originator Name: Open/Closed: Closed Release: dev Operating System: Any

You are not logged in

## Discussion

Wed 18 Apr 2018 05:42:02 PM UTC, comment #1:

This is okay.  See the documentation for the if statement in the Octave manual.

The condition in an if statement is considered true if its value is nonzero, and false if
its value is zero. If the value of the conditional expression in an if statement is a vector or
a matrix, it is considered true only if it is non-empty and all of the elements are nonzero.
The conceptually equivalent code when condition is a matrix is shown below.
if (matrix) ≡ if (all (matrix(:)))

And as an example,

if ([1 0 1])
disp ("1 0 1 is true");
else
disp ("1 0 1 is false");
endif
1 0 1 is false

But,

if ([1 1 1])
disp ("1 1 1 is true");
else
disp ("1 1 1 is false");
endif
1 1 1 is true

Rik <rik5>
Wed 18 Apr 2018 07:38:50 AM UTC, original submission:

delaunayn has this code fragment:

X = pts(T(i,1:end-1),:) - pts(T(i,2:end),:);
if (abs (det (X)) / sqrt (sumsq (X, 2)) < tol)
idx(end+1) = i;
endif

in the 2-D case X is a 2x2 matrix, sumsq(X,2) a [2x1] vector, det(X) a scalar.

The "if" is evaluated on a 2x1 vector of logicals. Shouldn't there be an all or any, e.g.:

if all(abs (det (X)) / sqrt (sumsq (X, 2)) < tol))

A.R. Burgers <arb>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by rik5 (Posted a comment)
• -email is unavailable- added by arb (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.