| 31 |
|
if ((nrows <= 0) | (ncols <= 0)) |
| 32 |
|
error(USER, "attempt to create empty matrix"); |
| 33 |
|
cm = (CMATRIX *)malloc(sizeof(CMATRIX) + |
| 34 |
< |
3*sizeof(COLORV)*(nrows*ncols - 1)); |
| 34 |
> |
sizeof(COLOR)*(nrows*ncols - 1)); |
| 35 |
|
if (cm == NULL) |
| 36 |
|
error(SYSTEM, "out of memory in cm_alloc()"); |
| 37 |
|
cm->nrows = nrows; |
| 50 |
|
return(NULL); |
| 51 |
|
} |
| 52 |
|
cm = (CMATRIX *)realloc(cm, sizeof(CMATRIX) + |
| 53 |
< |
3*sizeof(COLORV)*(nrows*cm->ncols - 1)); |
| 53 |
> |
sizeof(COLOR)*(nrows*cm->ncols - 1)); |
| 54 |
|
if (cm == NULL) |
| 55 |
|
error(SYSTEM, "out of memory in cm_resize()"); |
| 56 |
|
cm->nrows = nrows; |
| 173 |
|
int nread = 0; |
| 174 |
|
do { /* read all we can */ |
| 175 |
|
nread += fread(cm->cmem + 3*nread, |
| 176 |
< |
3*sizeof(COLORV), |
| 176 |
> |
sizeof(COLOR), |
| 177 |
|
cm->nrows*cm->ncols - nread, |
| 178 |
|
fp); |
| 179 |
|
if (nrows <= 0) { /* unknown length */ |
| 315 |
|
for (dr = 0; dr < cmr->nrows; dr++) |
| 316 |
|
for (dc = 0; dc < cmr->ncols; dc++) { |
| 317 |
|
COLORV *dp = cm_lval(cmr,dr,dc); |
| 318 |
+ |
double res[3]; |
| 319 |
|
dp[0] = dp[1] = dp[2] = 0; |
| 320 |
|
if (rowcheck != NULL && !rowcheck[dr]) |
| 321 |
|
continue; |
| 322 |
|
if (colcheck != NULL && !colcheck[dc]) |
| 323 |
|
continue; |
| 324 |
+ |
res[0] = res[1] = res[2] = 0; |
| 325 |
|
for (i = 0; i < cm1->ncols; i++) { |
| 326 |
|
const COLORV *cp1 = cm_lval(cm1,dr,i); |
| 327 |
|
const COLORV *cp2 = cm_lval(cm2,i,dc); |
| 328 |
< |
dp[0] += cp1[0] * cp2[0]; |
| 329 |
< |
dp[1] += cp1[1] * cp2[1]; |
| 330 |
< |
dp[2] += cp1[2] * cp2[2]; |
| 328 |
> |
res[0] += cp1[0] * cp2[0]; |
| 329 |
> |
res[1] += cp1[1] * cp2[1]; |
| 330 |
> |
res[2] += cp1[2] * cp2[2]; |
| 331 |
|
} |
| 332 |
+ |
copycolor(dp, res); |
| 333 |
|
} |
| 334 |
|
if (rowcheck != NULL) free(rowcheck); |
| 335 |
|
if (colcheck != NULL) free(colcheck); |