octave-maintainers
[Top][All Lists]
Advanced

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

Getting rid of warnings in Qhull related code, and confhulln() issues


From: Daniel J Sebald
Subject: Getting rid of warnings in Qhull related code, and confhulln() issues
Date: Thu, 30 Aug 2012 20:51:30 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

John,

The other day we discussed Flex and the fact there is a C++ interface in t works. Apparently the same is true of Qhull. E.g.,

http://gitorious.org/qhull/qhull/blobs/master/src/libqhullcpp/Qhull.h

Not sure it is worth the effort in this case (given how small the code/macro use is in Octave). In the long run, perhaps. But I think there might be a better way of suppressing the warnings.

Before getting any further, I'd like to point out some things about convhulln.cc.

I've attached a small change that replaces a "return" with a "break". If the routine were to return inside that loop (which I don't think it currently does), there would be a memory leak. That is, the memory created by the qhull routines wouldn't be freed after the end of the loop.

The conditional test breaks out of the loop if there is a non-simplicial facet and the user specified option QJ. It seems one can put anything in for options to the convhulln() routine (even nonsensical stuff) and it doesn't matter much. The options don't seem to be used in any meaningful way, other than that QJ break out.

So, back to what initiated this--the warnings. I was thinking a way to get rid of these warnings:

../../octave/libinterp/dldfcn/__voronoi__.cc: In function 'octave_value_list F__voronoi__(const octave_value_list&, int)': ../../octave/libinterp/dldfcn/__voronoi__.cc:197:11: warning: use of old-style cast ../../octave/libinterp/dldfcn/__voronoi__.cc:277:11: warning: use of old-style cast ../../octave/libinterp/dldfcn/convhulln.cc: In function 'octave_value_list Fconvhulln(const octave_value_list&, int)': ../../octave/libinterp/dldfcn/convhulln.cc:200:15: warning: use of old-style cast ../../octave/libinterp/dldfcn/convhulln.cc:211:19: warning: use of old-style cast ../../octave/libinterp/dldfcn/convhulln.cc:218:19: warning: use of old-style cast ../../octave/libinterp/dldfcn/convhulln.cc:218:19: warning: use of old-style cast ../../octave/libinterp/dldfcn/convhulln.cc:218:19: warning: use of old-style cast

is to take all the code in __voronoi__.cc and convhulln.cc that is qhull related and put that in a c-file called "qhcore.c" with an appropriate header. Then in __voronoi__.cc and convhulln.cc would be something like:

#include "qhcore.h"
...
memptr = <create_some_memory>  // A location to store Qhull's results
qh_convhulln (dim, num_points, points.fortran_vec (),
              ismalloc, cmd_str, outfile, errfile, memptr);
Matrix idx (nf, dim + 1);
octave_idx_type i = 0;
for (; i<ilen; i++)
  {
    octave_idx_type j = 0;
    for (; j<jlen; j++)
      idx(i, j) = memptr(j + N*i);
  }
  free(memptr);

The idea is to keep all the Qhull function/macro code in a C-file and use a little hook to the Octave function equivalents.

Do either of these (macros in C-file, or more robust 'options') sound like something worth doing?

Dan

Attachment: octave-convhulln-2012aug30.patch
Description: Text Data


reply via email to

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