| 11 |
|
#include "standard.h" |
| 12 |
|
#include "cmatrix.h" |
| 13 |
|
#include "platform.h" |
| 14 |
< |
#include "rtprocess.h" |
| 14 |
> |
#include "paths.h" |
| 15 |
|
#include "resolu.h" |
| 16 |
|
|
| 17 |
|
const char *cm_fmt_id[] = { |
| 148 |
|
CMATRIX * |
| 149 |
|
cm_load(const char *inspec, int nrows, int ncols, int dtype) |
| 150 |
|
{ |
| 151 |
< |
FILE *fp = stdin; |
| 152 |
< |
CMATRIX *cm; |
| 151 |
> |
const int ROWINC = 2048; |
| 152 |
> |
FILE *fp = stdin; |
| 153 |
> |
CMATRIX *cm; |
| 154 |
|
|
| 155 |
|
if (inspec == NULL) |
| 156 |
|
inspec = "<stdin>"; |
| 219 |
|
int r, c; |
| 220 |
|
for (r = 0; r < maxrow; r++) { |
| 221 |
|
if (r >= cm->nrows) /* need more space? */ |
| 222 |
< |
cm = cm_resize(cm, 2*cm->nrows); |
| 222 |
> |
cm = cm_resize(cm, cm->nrows+ROWINC); |
| 223 |
|
for (c = 0; c < ncols; c++) { |
| 224 |
|
COLORV *cv = cm_lval(cm,r,c); |
| 225 |
< |
if (fscanf(fp, COLSPEC, cv, cv+1, cv+2) != 3) |
| 225 |
> |
if (fscanf(fp, COLSPEC, cv, cv+1, cv+2) != 3) { |
| 226 |
|
if ((nrows <= 0) & (r > 0) & !c) { |
| 227 |
|
cm = cm_resize(cm, maxrow=r); |
| 228 |
|
break; |
| 229 |
|
} else |
| 230 |
|
goto EOFerror; |
| 231 |
+ |
} |
| 232 |
|
} |
| 233 |
|
} |
| 234 |
|
while ((c = getc(fp)) != EOF) |
| 250 |
|
if (nrows <= 0) { /* unknown length */ |
| 251 |
|
if (nread == cm->nrows*cm->ncols) |
| 252 |
|
/* need more space? */ |
| 253 |
< |
cm = cm_resize(cm, 2*cm->nrows); |
| 253 |
> |
cm = cm_resize(cm, cm->nrows+ROWINC); |
| 254 |
|
else if (nread && !(nread % cm->ncols)) |
| 255 |
|
/* seem to be done */ |
| 256 |
|
cm = cm_resize(cm, nread/cm->ncols); |
| 402 |
|
for (i = 0; i < cm1->ncols; i++) { |
| 403 |
|
const COLORV *cp1 = cm_lval(cm1,dr,i); |
| 404 |
|
const COLORV *cp2 = cm_lval(cm2,i,dc); |
| 405 |
< |
res[0] += (double)cp1[0] * (double)cp2[0]; |
| 406 |
< |
res[1] += (double)cp1[1] * (double)cp2[1]; |
| 407 |
< |
res[2] += (double)cp1[2] * (double)cp2[2]; |
| 405 |
> |
res[0] += cp1[0] * cp2[0]; |
| 406 |
> |
res[1] += cp1[1] * cp2[1]; |
| 407 |
> |
res[2] += cp1[2] * cp2[2]; |
| 408 |
|
} |
| 409 |
|
copycolor(dp, res); |
| 410 |
|
} |