comparison src/ls-mat5.cc @ 5933:1bcd9dd629c3

[project @ 2006-08-17 08:01:14 by jwe]
author jwe
date Thu, 17 Aug 2006 08:01:14 +0000
parents a703198cb8b8
children 117052c2b53c
comparison
equal deleted inserted replaced
5932:51cbaa2539f4 5933:1bcd9dd629c3
1350 1350
1351 ret += PAD (4 * tc.ndims ()); 1351 ret += PAD (4 * tc.ndims ());
1352 1352
1353 if (tc.is_string ()) 1353 if (tc.is_string ())
1354 { 1354 {
1355 charMatrix chm = tc.char_matrix_value (); 1355 charNDArray chm = tc.char_array_value ();
1356 ret += 8; 1356 ret += 8;
1357 if (chm.nelem () > 1) 1357 if (chm.nelem () > 2)
1358 ret += PAD (2 * chm.rows () * chm.cols ()); 1358 ret += PAD (2 * chm.nelem ());
1359 } 1359 }
1360 else if (cname == "sparse") 1360 else if (cname == "sparse")
1361 { 1361 {
1362 if (tc.is_complex_type ()) 1362 if (tc.is_complex_type ())
1363 { 1363 {
1616 } 1616 }
1617 1617
1618 // data element 1618 // data element
1619 if (tc.is_string ()) 1619 if (tc.is_string ())
1620 { 1620 {
1621 charMatrix chm = tc.char_matrix_value (); 1621 charNDArray chm = tc.char_array_value ();
1622 int nr = chm.rows (); 1622 int nel = chm.nelem ();
1623 int nc = chm.cols (); 1623 int len = nel*2;
1624 int len = nr*nc*2; 1624 int paddedlength = PAD (len);
1625 int paddedlength = PAD (nr*nc*2); 1625
1626 1626 OCTAVE_LOCAL_BUFFER (int16_t, buf, nel+3);
1627 OCTAVE_LOCAL_BUFFER (int16_t, buf, nc*nr+3);
1628 write_mat5_tag (os, miUINT16, len); 1627 write_mat5_tag (os, miUINT16, len);
1629 1628
1630 for (int i = 0; i < nr; i++) 1629 const char *s = chm.data ();
1631 { 1630
1632 std::string tstr = chm.row_as_string (i); 1631 for (int i = 0; i < nel; i++)
1633 const char *s = tstr.data (); 1632 buf[i] = *s++ & 0x00FF;
1634 1633
1635 for (int j = 0; j < nc; j++) 1634 os.write (reinterpret_cast<char *> (buf), len);
1636 buf[j*nr+i] = *s++ & 0x00FF;
1637 }
1638 os.write (reinterpret_cast<char *> (buf), nr*nc*2);
1639 1635
1640 if (paddedlength > len) 1636 if (paddedlength > len)
1641 os.write (reinterpret_cast<char *> (buf), paddedlength - len); 1637 {
1638 static char padbuf[9]="\x00\x00\x00\x00\x00\x00\x00\x00";
1639 os.write (padbuf, paddedlength - len);
1640 }
1642 } 1641 }
1643 else if (cname == "sparse") 1642 else if (cname == "sparse")
1644 { 1643 {
1645 if (tc.is_complex_type ()) 1644 if (tc.is_complex_type ())
1646 { 1645 {