changeset 530:0ebf2a6a83ee

Add eprint, notes on formatting
author Chris Cannam
date Mon, 03 Mar 2014 09:20:18 +0000
parents 39eba7d98ba1
children 77ada441f95a 7677fbebeec6
files src/may/complex.yeti src/may/matrix.yeti src/may/matrix/complex.yeti
diffstat 3 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/may/complex.yeti	Fri Feb 14 11:54:45 2014 +0000
+++ b/src/may/complex.yeti	Mon Mar 03 09:20:18 2014 +0000
@@ -31,6 +31,7 @@
         fi,
     String format()
        (f v r =
+       //!!! not right -- want to round to 1dp of exp notation if less than 1e-4
            (n = mm.round (v * 10000);
             s = "\(n / 10000)";
             if r then
--- a/src/may/matrix.yeti	Fri Feb 14 11:54:45 2014 +0000
+++ b/src/may/matrix.yeti	Mon Mar 03 09:20:18 2014 +0000
@@ -880,14 +880,16 @@
             [ "\nColumns \(c0) to \(c1)\n",
               (map do row:
                    map do v:
-                       n = mm.round (v * 10000);
-                       strPad ' ' 10 "\(n / 10000)";
+                   //!!! not right -- want to round to 1dp of exp notation if less than 1e-4
+                       n = mm.round (v * 100000);
+                       strPad ' ' 10 "\(n / 100000)";
                    done (vec.list row) |> strJoin "";
                done (asRows (columnSlice m c0 (c1 + 1))) |> strJoin "\n")
             ];
         done [0..width m / chunk - 1] |> concat);
 
-print' = print . format;
+print' = println . format;
+eprint' = eprintln . format;
 
 //!!! todo: look at all occurrences of matrix (and complexmatrix)
 // construction and make sure we have good apis for those use cases.
@@ -950,6 +952,7 @@
     enumerate,
     format,
     print = print',
+    eprint = eprint',
 }
 as
 {
@@ -1008,5 +1011,6 @@
     enumerate is matrix_t -> list<{ i is number, j is number, v is number }>,
     format is matrix_t -> string,
     print is matrix_t -> (),
+    eprint is matrix_t -> (),
 }
 
--- a/src/may/matrix/complex.yeti	Fri Feb 14 11:54:45 2014 +0000
+++ b/src/may/matrix/complex.yeti	Mon Mar 03 09:20:18 2014 +0000
@@ -307,7 +307,8 @@
             ];
         done [0..width m / chunk - 1] |> concat);
 
-print' = print . format;
+print' = println . format;
+eprint' = eprintln . format;
 
 {
     size,
@@ -350,6 +351,7 @@
     enumerate,
     format,
     print = print',
+    eprint = eprint',
 } as {
     size is complexmatrix_t -> { rows is number, columns is number },
     width is complexmatrix_t -> number,
@@ -394,5 +396,6 @@
     enumerate is complexmatrix_t -> list<{ i is number, j is number, v is cpx.complex_t }>,
     format is complexmatrix_t -> string,
     print is complexmatrix_t -> (),
+    eprint is complexmatrix_t -> (),
 }