23 #include "lv_prolog.h" 45 T &
xy(
int col,
int row) {
46 return elem[row*dimSizes[1]+col];
48 T&
get(
int row,
int col) {
49 return elem[row*dimSizes[1]+col];
51 int numElem() {
return dimSizes[0]*dimSizes[1]; }
61 int numElem() {
return dimSizes[0]*dimSizes[1]*dimSizes[2]; }
65 template<
typename T,
int N>
72 for (
int i=1;i<N;i++) n*=dimSizes[i];
77 #ifndef DOXYGEN // Hide these structs from documentation (why not a single enum?) 81 template<
typename T>
struct LVDataType {};
82 template<>
struct LVDataType<float> {
enum { code=9 }; };
83 template<>
struct LVDataType<double> {
enum { code=10 }; };
84 template<>
struct LVDataType<int8_t> {
enum { code=1 }; };
85 template<>
struct LVDataType<int16_t> {
enum { code=2 }; };
86 template<>
struct LVDataType<int32_t> {
enum { code=3 }; };
87 template<>
struct LVDataType<int64_t> {
enum { code=4 }; };
88 template<>
struct LVDataType<uint8_t> {
enum { code=5 }; };
89 template<>
struct LVDataType<uint16_t> {
enum { code=6 }; };
90 template<>
struct LVDataType<uint32_t> {
enum { code=7 }; };
91 template<>
struct LVDataType<uint64_t> {
enum { code=8 }; };
92 template<>
struct LVDataType<std::complex<float> > {
enum { code=0xc }; };
93 template<>
struct LVDataType<std::complex<double> > {
enum { code=0xd }; };
100 if (NumericArrayResize(LVDataType<T>::code, 2, (UHandle*)&d,
sizeof(T)*rows*cols) != mgNoErr)
101 throw std::runtime_error(
SPrintf(
"NumericArrayResize(2D array, %d, %d) returned error.", rows,cols));
102 (*d)->dimSizes[0] = rows;
103 (*d)->dimSizes[1] = cols;
109 if (NumericArrayResize(LVDataType<T>::code, 3, (UHandle*)&d,
sizeof(T)*rows*cols*depth) != mgNoErr)
110 throw std::runtime_error(
SPrintf(
"NumericArrayResize(3D array, %d, %d, %d) returned error.", depth,rows,cols));
112 (*d)->dimSizes[0] = depth;
113 (*d)->dimSizes[1] = rows;
114 (*d)->dimSizes[2] = cols;
117 template<
typename T,
int N>
120 for (
int i=0;i<N;i++)
121 (*d)->dimSizes[i]=dims[i];
122 NumericArrayResize(LVDataType<T>::code, N, (UHandle*)&d,
sizeof(T)*(*d)->
numElem());
128 if (NumericArrayResize(LVDataType<T>::code, 1, (UHandle*)&d,
sizeof(T)*elems) != mgNoErr)
129 throw std::runtime_error(
SPrintf(
"NumericArrayResize(1D array, %d) returned error.", elems));
130 (*d)->dimSize = elems;
133 #include "lv_epilog.h" 137 void SetLVString (LStrHandle str,
const char *text);
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
void SetLVString(LStrHandle str, const char *text)
void ResizeLVArray(LVArrayND< T, N > **&d, int *dims)
void ResizeLVArray3D(LVArray3D< T > **&d, int depth, int rows, int cols)
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
LabVIEW N dimensions array template.
LabVIEW 3D Array template.
LabVIEW 2D Array template.
std::vector< std::string > LVGetStringArray(int count, LStrHandle *str)
Abstract tracker interface, implemented by QueuedCUDATracker and QueuedCPUTracker.
std::string SPrintf(const char *fmt,...)
MgErr FillErrorCluster(MgErr err, const char *message, ErrorCluster *error)