59 |
|
{ |
60 |
|
if (!info || !*info) |
61 |
|
return(0); |
62 |
< |
if (!rm->info) |
62 |
> |
if (!rm->info) { |
63 |
|
rm->info = (char *)malloc(strlen(info)+1); |
64 |
< |
else |
64 |
> |
if (rm->info) rm->info[0] = '\0'; |
65 |
> |
} else |
66 |
|
rm->info = (char *)realloc(rm->info, |
67 |
|
strlen(rm->info)+strlen(info)+1); |
68 |
|
if (!rm->info) |
246 |
|
case DTascii: |
247 |
|
if (!rmx_load_ascii(dnew, fp)) |
248 |
|
goto loaderr; |
249 |
+ |
dnew->dtype = DTascii; /* should leave double? */ |
250 |
|
break; |
251 |
|
case DTfloat: |
252 |
|
if (!rmx_load_float(dnew, fp)) |
357 |
|
} |
358 |
|
|
359 |
|
/* Write matrix to file type indicated by dtype */ |
360 |
< |
long |
360 |
> |
int |
361 |
|
rmx_write(const RMATRIX *rm, int dtype, FILE *fp) |
362 |
|
{ |
363 |
|
RMATRIX *mydm = NULL; |
372 |
|
dtype = rm->dtype; |
373 |
|
else if ((dtype == DTrgbe) & (rm->dtype == DTxyze)) |
374 |
|
dtype = DTxyze; |
375 |
< |
else if ((dtype = DTxyze) & (rm->dtype == DTrgbe)) |
375 |
> |
else if ((dtype == DTxyze) & (rm->dtype == DTrgbe)) |
376 |
|
dtype = DTrgbe; |
377 |
|
if ((dtype != DTrgbe) & (dtype != DTxyze)) { |
378 |
|
fprintf(fp, "NROWS=%d\n", rm->nrows); |
410 |
|
} |
411 |
|
ok &= (fflush(fp) == 0); |
412 |
|
rmx_free(mydm); |
413 |
< |
return(ftell(fp) * ok); /* return # bytes written */ |
413 |
> |
return(ok); |
414 |
|
} |
415 |
|
|
416 |
|
/* Allocate and assign square identity matrix with n components */ |
493 |
|
rmx_addinfo(mres, rmx_mismatch_warn); |
494 |
|
for (i = mres->nrows; i--; ) |
495 |
|
for (j = mres->ncols; j--; ) |
496 |
< |
for (h = m1->ncols; h--; ) { |
496 |
> |
for (k = mres->ncomp; k--; ) { |
497 |
|
long double d = 0; |
498 |
< |
for (k = mres->ncomp; k--; ) |
498 |
> |
for (h = m1->ncols; h--; ) |
499 |
|
d += (long double)rmx_lval(m1,i,h,k) * |
500 |
|
(long double)rmx_lval(m2,h,j,k); |
501 |
|
rmx_lval(mres,i,j,k) = (double)d; |