[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to access underlying C datatype of octave [u]int{8|16|32|64}NDArray?
From: |
Benjamin Lindner |
Subject: |
How to access underlying C datatype of octave [u]int{8|16|32|64}NDArray? |
Date: |
Wed, 21 Mar 2007 13:57:43 +0100 |
Hello list,
What is the preferred (or best) way to get access to the underlying
C Datatypes of the octave integer Arrays?
I am using an int32NDArray and would like to retrieve a pointer to
int32_t which is the internal datatype. The member functions data() and
fortran_vec() return pointers to the octave_int32 type, which does not
behave like a C integer (which is in my case necessary).
One solution that (at least syntactically) works is to use
reinterpret_cast<>, but it there a more elegant solution?
Imagine C++ Code like:
#include <octave/oct.h>
#include <octave/oct-intytpes.h>
template <class T> int foo( const T* pIN, size_t len_in, T* pOUT ) {
// do something in here...
// T must be a built-in C integer type
}
DEFUN_DLD( foo, args, , "out=foo(in)" ) {
int32NDArray sigin( args(0).array_value() );
unsigned int len_sigin = args(0).length();
int32NDArray sigout( dim_vector(len_sigin, 1), 0 );
// IS THIS THE PREFERRED WAY ??
const int32_t* pIN = reinterpret_cast<const int32_t*>( sigin.data() );
int32_t* pOUT = reinterpret_cast<int32_t*>( sigout.fortran_vec() );
// call template
unsigned int t = foo( pIN, len_sigin, pOUT );
...
}
thanks for hints
benjamin
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: www.gmx.net/de/go/mailfooter/topmail-out
- How to access underlying C datatype of octave [u]int{8|16|32|64}NDArray?,
Benjamin Lindner <=