[e478b6]: timing / profiling / matLoader.h  Maximize  Restore  History

Download this file

73 lines (60 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "mat.h"
#include <string.h>
int getNoOfArgsFromMAT(const char* file)
{
MATFile *pmat;
const char **dir;
int ndir;
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error opening file %s\n", file);
return(1);
}
dir = (const char **)matGetDir(pmat, &ndir);
mxFree(dir);
if (matClose(pmat) != 0) {
printf("Error closing file %s\n",file);
return(1);
}
return ndir;
}
int getArgsFromMAT(const char* file, mxArray* prhs[], int ndir)
{
MATFile *pmat;
const char *name;
int ii;
mxArray *pa;
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error reopening file %s\n", file);
return;
}
/* Read in each array. */
//printf("\nReading in the actual array contents:\n");
for (ii=0; ii<ndir; ii++) {
pa = matGetNextVariable(pmat, &name);
if(strncmp(name,"arg",3))
{
printf("Variable name shoud be in the following format: arg## \n");
return -1;
}
char buf[4];
memcpy(buf,name+3,strlen(name)-3);
int idx = atoi(buf);
if(!(idx<ndir))
{
printf("Variable name shoud be in the following format: arg##, where ## is argument number less than total arg. count. \n");
return -1;
}
if (pa == NULL) {
printf("Error reading in file %s\n", file);
return -1;
}
prhs[idx] = pa;
}
if (matClose(pmat) != 0) {
printf("Error closing file %s\n",file);
return -1;
}
return 0;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks