[sac-user] print function alternatives?

Nil Karavadara n.karavadara at gmail.com
Thu Aug 5 20:31:59 CEST 2010


Dear Michael,

Necessary changes has been made in order to provide format support in printing.
In order to enable this on your machine you need to follow this steps:

1) Replace file "ArrayIO.sac" in "stdlib/world/stdio"
2) Replace file "PrintArray.c" in "stdlib/world/stdio/src/ArrayIO"
3) Compile the standard library (stdlib)

Please find ArrayIO.sac, PrintArray.c attached.

After this you will be able to provide format string as a parameter to
print function call,

use Array:all;
use StdIO:all;
int main()
{
 x = 0.07;
 z = tod(reshape([5,5],iota(25)));
 print(x);
 print(z);
 print("%30.20f",z);
 return(0);
}

As you can see there is two way you can print now, if no format string
provided then it prints using default format (line 7,8), or you can
specify the format string (line 9). The output of example is attached.


If you have any further comments or queries please do not hesitate to
contact me.



On Mon, Aug 2, 2010 at 5:20 PM, Bullington, Michael
<michael.bullington at ttu.edu> wrote:
> To whom it shall concern:
>
>
>
> I was tracing some logic errors on a program that would perform Singular
> Value Decomposition (SVD) and was using the print function to print values
> in tracking the logic errors.  However, I had to resort to more “standard”
> printf functions using %30.15f format strings (up to 15 decimal places) to
> discover I had computation round-off errors.  The round-off errors became
> extremely deceptive when the print function was used in tracking the errors
> because the rounding gave output the appearance of correctness.  The print
> function in SAC seems to just use the “standard” %f format string which has
> a default of 6 decimal places.
>
>
>
> Is there an alternative (overloaded) form of the print function in SAC where
> I can control some of the output formatting and not have to resort to
> printf?
>
>
>
> _______________________________________________
> sac-user mailing list
> sac-user at sac-home.org
> http://lists.sac-home.org/mailman/listinfo.cgi/sac-user
>
>



-- 
Kind Regards,
Nil Karavadara

Science and Technology Research Institute
University of Hertfordshire
-------------- next part --------------
Dimension:  0
Shape    : < >
 0.07

Dimension:  2
Shape    : <  5,  5>
|0.000000e+00 1.000000e+00 2.000000e+00 3.000000e+00 4.000000e+00 | 
|5.000000e+00 6.000000e+00 7.000000e+00 8.000000e+00 9.000000e+00 | 
|1.000000e+01 1.100000e+01 1.200000e+01 1.300000e+01 1.400000e+01 | 
|1.500000e+01 1.600000e+01 1.700000e+01 1.800000e+01 1.900000e+01 | 
|2.000000e+01 2.100000e+01 2.200000e+01 2.300000e+01 2.400000e+01 | 

Dimension:  2
Shape    : <  5,  5>
|        0.00000000000000000000        1.00000000000000000000        2.00000000000000000000        3.00000000000000000000        4.00000000000000000000| 
|        5.00000000000000000000        6.00000000000000000000        7.00000000000000000000        8.00000000000000000000        9.00000000000000000000| 
|       10.00000000000000000000       11.00000000000000000000       12.00000000000000000000       13.00000000000000000000       14.00000000000000000000| 
|       15.00000000000000000000       16.00000000000000000000       17.00000000000000000000       18.00000000000000000000       19.00000000000000000000| 
|       20.00000000000000000000       21.00000000000000000000       22.00000000000000000000       23.00000000000000000000       24.00000000000000000000| 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ArrayIO.sac
Type: application/octet-stream
Size: 4340 bytes
Desc: not available
URL: <http://lists.sac-home.org/pipermail/sac-user/attachments/20100805/1219632e/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PrintArray.c
Type: text/x-csrc
Size: 9714 bytes
Desc: not available
URL: <http://lists.sac-home.org/pipermail/sac-user/attachments/20100805/1219632e/attachment.c>


More information about the sac-user mailing list