help-octave
[Top][All Lists]
Advanced

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

octave datatypes and c datatypes Is there a 1 a 1 relationship between a


From: Riccardo Corradini
Subject: octave datatypes and c datatypes Is there a 1 a 1 relationship between arrays?
Date: Mon, 12 Mar 2007 17:09:57 +0100 (CET)

Hi all,
I would like to know if there is one to one relationship between octave datatypes and C data types
For istance I defined the following macro
#define UPACK_INT_ARRAY(CASE,FTYPE,PRMTYP, PTRTYP)    \
/*---------------------------------------*/                \
int unpack_##CASE##_mat(const PRMTYP &array){                \
/*---------------------------------------*/                \
  int n  = array.nelem();                        \
  int info;                                \
  const PTRTYP *pointer  = reinterpret_cast<const PTRTYP *>(array.fortran_vec());            \
  if((info=FTYPE(pointer,n,1))) return(info);    \
  return(PvmOk);                            \
}

  UPACK_INT_ARRAY(i8 ,pvm_upkbyte, int8NDArray ,          char)
  UPACK_INT_ARRAY(i16,pvm_upkshort ,int16NDArray,          short)
  UPACK_INT_ARRAY(i32,pvm_upkint ,int32NDArray,          int)

  UPACK_INT_ARRAY(u8 ,pvm_upkbyte ,uint8NDArray , char)
  UPACK_INT_ARRAY(u16,pvm_upkushort ,uint16NDArray, unsigned short)
  UPACK_INT_ARRAY(u32,pvm_upkuint ,uint32NDArray, unsigned int)


I am sure that even if it might work it is not the right procedure suggested in general by JWE,so what is the best strategy to convert an int .. array into a c array and viceversa. Is it possible to avoid reinterpret cast etc..
Thanks in advance to all
Riccardo


L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail
reply via email to

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