Catching Acces Violation/Segmentation Fault

Bill Baxter dnewsgroup at billbaxter.com
Wed May 9 10:34:18 PDT 2007


Silverling wrote:
> I am programming a Matrix class to be used like a primitive type (overloaded operators, identity, transpose, the whole shebang) and one of the constructors _may_ cause an Access Violation (or Segmentation Fault, if you prefer the old Linux SIGSEG) if the class's user is foolish. Is there a way to catch this errors?
> 
> Secondly, would this class be of any use to anyone? I'll gladly distribute it all around (OpenSourced, of course). It is 'templatized'. I'm unsure if Phobos or Tango would want such class if I submited it.

What are the specifics of your class?  Is it an arbitrary MxN sized 
matrix?  Will it use vendor-provided accelerated BLAS libraries where 
available?  Is it parameterized on element type?  Storage format? Can it 
handle different storage schemes (e.g. sparse formats like CSC, CSR, 
banded, symmetric).  If it's got all that, then I'm definitely 
interested.  A port of something like Boost::ublas would be great. 
(http://www.boost.org/libs/numeric/ublas/doc/index.htm).

I've started on a multidimensional array class that can be used as a 
matrix if desired.  It's based loosely on NumPy's multidimensional 
arrays.  http://www.dsource.org/projects/multiarray.html .   It's hooked 
up to BLAS and LAPACK for some basic operations like multiplication, 
linear system solving, and least squares problems.   Doesn't do sparse 
at all though.

Oskar Linde also posted a multidim array struct a while back.  Same 
basic philosophy, but using a struct instead of a class.  I'm probably 
going to switch over to using a struct eventually too, once D gets const 
ref.

--bb


More information about the Digitalmars-d-learn mailing list