help-octave
[Top][All Lists]
Advanced

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

## RE: Question about how to use an existing octave function in a cc code

 From: THOMAS Paul Richard Subject: RE: Question about how to use an existing octave function in a cc code Date: Fri, 6 Feb 2004 09:49:21 +0100

```Wen-shiang,

If your matrices are 2 by 10, I would seriously doubt that it is worth your
while writing a DLD.  However, if this is an in principle test, I suggest
that you peruse some of the examples of DLDs in the mailing lists that make
use of feval (with which you could call randn):

eg http://www.octave.org/mailing-lists/help-octave/2003/1809

is a good example because it illustrates not only the use of feval (which
you would use to call randn) but also checking of arguments of the DLD.

If you do not wish to suffer the performance loss that results from calling
the interpreter, you can call the octave library routines directly, using
your_octave/src/DLD-FUNCTIONS/rand.cc as the template, or, more simply, the
C library rand(), used with srand(seed) for initialisation.

Paul

-----Message d'origine-----
De : Wen-shiang Chen [mailto:address@hidden
Envoyé : jeudi 5 février 2004 23:43
À : help-octave
Cc : address@hidden
Objet : Question about how to use an existing octave function in a cc
code

Sorry to ask such a newbie question!  I have very limited knowledge about
c++ programming and just start to learn how to program under octave.

My question is how to use existing octave functions, in this case, the
randn function, in my cc code?  The m-file looks like the following,
x=y+randn(2,10);
and my incomplete cc code looks like the follwing,
DEFUN_DLD (mycc, args, ,)
{
Matrix x (2,10);
Matrix y (2,10);

x=y+??
}

So could someone shed some light for me on how to write
x=y+randn(2,10);
in my cc code?  Thanks!

Wen-shiang Chen

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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.577 / Virus Database: 366 - Release Date: 03/02/04

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.577 / Virus Database: 366 - Release Date: 03/02/04

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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]
• RE: Question about how to use an existing octave function in a cc code, THOMAS Paul Richard <=