Mercurial > hg > octave-lyh
comparison src/pr-output.cc @ 4532:01ee68d18069
[project @ 2003-10-10 00:49:54 by jwe]
author | jwe |
---|---|
date | Fri, 10 Oct 2003 00:49:55 +0000 |
parents | 508238e65af7 |
children | 802818bfac91 |
comparison
equal
deleted
inserted
replaced
4531:b570d7825fb9 | 4532:01ee68d18069 |
---|---|
1483 } | 1483 } |
1484 } | 1484 } |
1485 } | 1485 } |
1486 } | 1486 } |
1487 | 1487 |
1488 #define PRINT_ND_ARRAY(os, nda, NDA_T, ELT_T, MAT_T) \ | |
1489 do \ | |
1490 { \ | |
1491 int ndims = nda.ndims (); \ | |
1492 \ | |
1493 dim_vector dims = nda.dims (); \ | |
1494 \ | |
1495 Array<int> ra_idx (ndims, 0); \ | |
1496 \ | |
1497 int m = 1; \ | |
1498 \ | |
1499 for (int i = 2; i < ndims; i++) \ | |
1500 m *= dims(i); \ | |
1501 \ | |
1502 int nr = dims(0); \ | |
1503 int nc = dims(1); \ | |
1504 \ | |
1505 for (int i = 0; i < m; i++) \ | |
1506 { \ | |
1507 std::string nm = "ans"; \ | |
1508 \ | |
1509 if (m > 1) \ | |
1510 { \ | |
1511 nm += "(:,:,"; \ | |
1512 \ | |
1513 OSSTREAM buf; \ | |
1514 \ | |
1515 for (int k = 2; k < ndims; k++) \ | |
1516 { \ | |
1517 buf << ra_idx(k) + 1; \ | |
1518 \ | |
1519 if (k < ndims - 1) \ | |
1520 buf << ","; \ | |
1521 else \ | |
1522 buf << ")"; \ | |
1523 } \ | |
1524 \ | |
1525 buf << OSSTREAM_ENDS; \ | |
1526 \ | |
1527 nm += OSSTREAM_STR (buf); \ | |
1528 \ | |
1529 OSSTREAM_FREEZE (buf); \ | |
1530 } \ | |
1531 \ | |
1532 Array<idx_vector> idx (ndims); \ | |
1533 \ | |
1534 idx(0) = idx_vector (':'); \ | |
1535 idx(1) = idx_vector (':'); \ | |
1536 \ | |
1537 for (int k = 2; k < ndims; k++) \ | |
1538 idx(k) = idx_vector (ra_idx(k) + 1); \ | |
1539 \ | |
1540 octave_value page \ | |
1541 = MAT_T (Array2<ELT_T> (nda.index (idx), nr, nc)); \ | |
1542 \ | |
1543 page.print_with_name (os, nm); \ | |
1544 \ | |
1545 if (i < m) \ | |
1546 NDA_T::increment_index (ra_idx, dims, 2); \ | |
1547 } \ | |
1548 } \ | |
1549 while (0) | |
1550 | |
1488 void | 1551 void |
1489 octave_print_internal (std::ostream& os, const NDArray& nda, | 1552 octave_print_internal (std::ostream& os, const NDArray& nda, |
1490 bool pr_as_read_syntax, int extra_indent) | 1553 bool pr_as_read_syntax, int extra_indent) |
1491 { | 1554 { |
1492 switch (nda.ndims ()) | 1555 switch (nda.ndims ()) |
1496 octave_print_internal (os, nda.matrix_value (), | 1559 octave_print_internal (os, nda.matrix_value (), |
1497 pr_as_read_syntax, extra_indent); | 1560 pr_as_read_syntax, extra_indent); |
1498 break; | 1561 break; |
1499 | 1562 |
1500 default: | 1563 default: |
1501 os << nda; | 1564 PRINT_ND_ARRAY (os, nda, NDArray, double, Matrix); |
1502 break; | 1565 break; |
1503 } | 1566 } |
1504 } | 1567 } |
1505 | 1568 |
1506 static inline void | 1569 static inline void |
1689 octave_print_internal (os, nda.matrix_value (), | 1752 octave_print_internal (os, nda.matrix_value (), |
1690 pr_as_read_syntax, extra_indent); | 1753 pr_as_read_syntax, extra_indent); |
1691 break; | 1754 break; |
1692 | 1755 |
1693 default: | 1756 default: |
1694 os << nda; | 1757 PRINT_ND_ARRAY (os, nda, ComplexNDArray, Complex, ComplexMatrix); |
1695 break; | 1758 break; |
1696 } | 1759 } |
1697 } | 1760 } |
1698 | 1761 |
1699 void | 1762 void |
1824 octave_print_internal (os, nda.matrix_value (), | 1887 octave_print_internal (os, nda.matrix_value (), |
1825 pr_as_read_syntax, extra_indent); | 1888 pr_as_read_syntax, extra_indent); |
1826 break; | 1889 break; |
1827 | 1890 |
1828 default: | 1891 default: |
1829 os << nda; | 1892 PRINT_ND_ARRAY (os, nda, boolNDArray, bool, boolMatrix); |
1830 break; | 1893 break; |
1831 } | 1894 } |
1832 } | 1895 } |
1833 | 1896 |
1834 void | 1897 void |
1890 octave_print_internal (os, nda.matrix_value (), | 1953 octave_print_internal (os, nda.matrix_value (), |
1891 pr_as_read_syntax, extra_indent, pr_as_string); | 1954 pr_as_read_syntax, extra_indent, pr_as_string); |
1892 break; | 1955 break; |
1893 | 1956 |
1894 default: | 1957 default: |
1895 os << nda; | 1958 PRINT_ND_ARRAY (os, nda, charNDArray, char, charMatrix); |
1896 break; | 1959 break; |
1897 } | 1960 } |
1898 } | 1961 } |
1899 | 1962 |
1900 extern void | 1963 extern void |