comparison src/ls-mat5.cc @ 5941:117052c2b53c

[project @ 2006-08-18 18:05:20 by jwe]
author jwe
date Fri, 18 Aug 2006 18:05:20 +0000
parents 1bcd9dd629c3
children c7105ffca0b6
comparison
equal deleted inserted replaced
5940:0dd8428bb260 5941:117052c2b53c
340 340
341 // Read one element tag from stream IS, 341 // Read one element tag from stream IS,
342 // place the type code in TYPE and the byte count in BYTES 342 // place the type code in TYPE and the byte count in BYTES
343 // return nonzero on error 343 // return nonzero on error
344 static int 344 static int
345 read_mat5_tag (std::istream& is, bool swap, int& type, int& bytes) 345 read_mat5_tag (std::istream& is, bool swap, int32_t& type, int& bytes)
346 { 346 {
347 unsigned int upper; 347 unsigned int upper;
348 int32_t temp; 348 int32_t temp;
349 349
350 if (! is.read (reinterpret_cast<char *> (&temp), 4 )) 350 if (! is.read (reinterpret_cast<char *> (&temp), 4 ))
402 // These are initialized here instead of closer to where they are 402 // These are initialized here instead of closer to where they are
403 // first used to avoid errors from gcc about goto crossing 403 // first used to avoid errors from gcc about goto crossing
404 // initialization of variable. 404 // initialization of variable.
405 405
406 oct_mach_info::float_format flt_fmt = oct_mach_info::flt_fmt_unknown; 406 oct_mach_info::float_format flt_fmt = oct_mach_info::flt_fmt_unknown;
407 int type = 0; 407 int32_t type = 0;
408 bool imag; 408 bool imag;
409 bool logicalvar; 409 bool logicalvar;
410 enum arrayclasstype arrayclass; 410 enum arrayclasstype arrayclass;
411 int32_t nzmax; 411 int32_t nzmax;
412 int32_t flags; 412 int32_t flags;
413 dim_vector dims; 413 dim_vector dims;
414 int len; 414 int32_t len;
415 int element_length; 415 int32_t element_length;
416 std::streampos pos; 416 std::streampos pos;
417 int16_t number; 417 int16_t number;
418 number = *(int16_t *)"\x00\x01"; 418 number = *(int16_t *)"\x00\x01";
419 419
420 global = false; 420 global = false;
1644 if (tc.is_complex_type ()) 1644 if (tc.is_complex_type ())
1645 { 1645 {
1646 SparseComplexMatrix m = tc.sparse_complex_matrix_value (); 1646 SparseComplexMatrix m = tc.sparse_complex_matrix_value ();
1647 int nc = m.cols (); 1647 int nc = m.cols ();
1648 1648
1649 write_mat5_integer_data (os, m.ridx (), - sizeof(int), nnz); 1649 int tmp = sizeof (int);
1650 write_mat5_integer_data (os, m.cidx (), - sizeof(int), nc + 1); 1650
1651 write_mat5_integer_data (os, m.ridx (), -tmp, nnz);
1652 write_mat5_integer_data (os, m.cidx (), -tmp, nc + 1);
1651 1653
1652 NDArray buf (dim_vector (nnz, 1)); 1654 NDArray buf (dim_vector (nnz, 1));
1653 1655
1654 for (int i = 0; i < nnz; i++) 1656 for (int i = 0; i < nnz; i++)
1655 buf (i) = std::real (m.data (i)); 1657 buf (i) = std::real (m.data (i));
1664 else 1666 else
1665 { 1667 {
1666 SparseMatrix m = tc.sparse_matrix_value (); 1668 SparseMatrix m = tc.sparse_matrix_value ();
1667 int nc = m.cols (); 1669 int nc = m.cols ();
1668 1670
1669 write_mat5_integer_data (os, m.ridx (), - sizeof(int), nnz); 1671 int tmp = sizeof (int);
1670 write_mat5_integer_data (os, m.cidx (), - sizeof(int), nc + 1); 1672
1673 write_mat5_integer_data (os, m.ridx (), -tmp, nnz);
1674 write_mat5_integer_data (os, m.cidx (), -tmp, nc + 1);
1671 1675
1672 // FIXME 1676 // FIXME
1673 // Is there a way to easily do without this buffer 1677 // Is there a way to easily do without this buffer
1674 NDArray buf (dim_vector (nnz, 1)); 1678 NDArray buf (dim_vector (nnz, 1));
1675 1679