[Top][All Lists]

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

Re: C++ Question

From: Paul Kienzle
Subject: Re: C++ Question
Date: Mon, 31 Mar 2003 20:39:06 -0500
User-agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.3a) Gecko/20021212

Quentin H. Spencer wrote:

Hello all,

I have been writing some functions in C that use the octave ComplexSVD class, and I'm having trouble understanding some strange behavior. Initially I wrote the function with the following syntax: ComplexSVD svd;
    svd = ComplexSVD( matrix , SVD::std);
ComplexMatrix U = svd.left_singular_matrix();

This is a copy constructor

Later I changed the syntax to the following (which mirrors the syntax used in

ComplexSVD svd( matrix , SVD::std);

This is a constructor.

    ComplexMatrix U    = svd.left_singular_matrix();

When using the first syntax, the function would usually return properly the first time, but subsequent runnings of my C++ function (and sometimes even octave's builtin svd function) often resulted in the following:

error: ComplexSVD: U not computed because type == SVD::sigma_only

This is usally followed by a segmentation fault. There could be some technicality about C++ that I don't understand here, but I don't see the different between these two implementations. Can anyone enlighten me?

The copy constructor code in liboctave/CmplxSVD.h, which is the function
  ComplexSVD& operator= (const ComplexSVD& a)
does not copy the type_computed variable, so it keeps the value it had
before the copy.  Since your svd is uninitalized it is assumes its default
value (which may be random --- I don't know what C++ does with
uninitialized enums).

Copy it, test it and send a patch to bug-octave.


Paul Kienzle

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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