~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to examples/mex-examples/cpp/temptst.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
extern "C" {
 
2
#include <mex.h>
 
3
}
 
4
#include "temptst.h"
 
5
 
 
6
 
 
7
extern N1<double> callsquare(N1<double> n1);
 
8
 
 
9
extern "C" {
 
10
  void mexFunction(int nlhs, Matrix** plhs, int nrhs, Matrix** prhs) {
 
11
    if (nrhs < 1)
 
12
      mexErrMsgTxt("Need at least one argument");
 
13
    if (mxGetM(prhs[0]) == 0)
 
14
      mexErrMsgTxt("First argument must have at least one entry");
 
15
    double* m = mxGetPr(prhs[0]);
 
16
    
 
17
    N1<double> ans = callsquare(N1<double>(*m));
 
18
    Matrix* result = mxCreateFull(1,1,REAL);
 
19
    *mxGetPr(result) = ans.data();
 
20
    plhs[0] = result;
 
21
    return;
 
22
  } 
 
23
}
 
24