📄 arrays-io.texi
字号:
@node Array I/O@section Inputting and Outputting Arrays@subsection Output formatting@cindex persistence@cindex Array persistence@cindex output formatting@cindex Array output formatting@cindex saving arrays@cindex writing arrays to output streams@cindex Array saving to output stream@cindex Array writing to output streamThe current version of Blitz++ includes rudimentary output formatting forarrays. Here's an example:@smallexample@include examples/output.texi@end smallexampleAnd the output:@smallexample@include examples/output.out@end smallexample@subsection Inputting arrays@cindex inputting arrays from an input stream@cindex Array inputting from istream@cindex restoring arrays from an input stream@cindex Array restoring from istreamArrays may be restored from an istream using the @code{>>} operator.@strong{Note:} you must know the dimensionality of the array being restoredfrom the stream. The @code{>>} operator expects an array in the same inputformat as generated by the @code{<<} operator, namely:@cindex Array persistence format@itemize @bullet@item The size of the array, for example ``32'' for a 1-dimensional array of32 elements, ``12 x 64 x 128'' for a 3-dimensional array of size 12x64x128.@item The symbol @code{'['} indicating the start of the array data@item The array elements, listed in memory storage order@item The symbol @code{']'} indicating the end of the array data@end itemizeThe operator prototype is:@example template<class T, int N>istream& operator>>(istream&, Array<T,N>&);@end example Here is an example of saving and restoring arrays from files. You can findthis example in the Blitz++ distribution as @file{examples/io.cpp}.@smallexample@include examples/io.texi@end smallexample@strong{Note:} The storage order and starting indices are not restored fromthe input stream. If you are restoring (for example) a Fortran-style array,you must create a Fortran-style array, and then restore it. For example,this code restores a Fortran-style array from the standard input stream:@example Array<float,2> B(fortranArray);cin >> B;@end example
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -