⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faq.texi

📁 A C++ class library for scientific computing
💻 TEXI
字号:
@section Questions about installation@cindex FAQ@cindex CRC error in .tar.gz@cindex invalid compressed data@faq{I downloaded Blitz++, but when I try to gunzip it, I get``invalid compressed data--crc error''}You forgot to set binary download mode in ftp.  Do so withthe ``binary'' command.@cindex Configuration/Install errors under Mac OS X@faq{After accessing blitz from the cvs repository, the ``autoreconf -fiv''command seems to fail mysteriously.}The current blitz autoconf build system uses libtool to manage buildingeither static or shared versions of the library.  Mac OS X systems have their own version of libtool and libtoolize that conflict with the GNU versions, so these have been renamed glibtool and glibtoolize.  You mustset environment variables to indicate the right tools to use.  Try this:@exampleexport LIBTOOL=/usr/bin/glibtoolexport LIBTOOLIZE=/usr/bin/glibtoolize@end example@cindex Fortran compiler requirement@faq{The blitz configure script fails to find a valid Fortran compiler.  Why the heck do I need a Fortran compiler for Blitz++ anyway?}A Fortran compiler is only needed to compile the Fortran portions of the blitz benchmark codes in the banchmarks subdirectory, which compare thespeed of blitz code to that of raw Fortran 77 or Fortran 90 arrays.  ManyDarwin systems do not come with a Fortran compiler installed by default,and it can be difficult to obtain a GNU Fortran compiler for Mac OS X thatis completely compatible with the default C/C++ compiler.  Therefore, theblitz configure script now provides the option --disable-fortran, which will skip over Fortran configuration.  This will render the benchmark codesunusable, but will allow you to build and install the blitz library.@cindex Undefined references@faq{The linker complains about undefined references when compiling my blitz application code.}Although almost all of blitz consists of inlined templated code providedin header files via @code{<blitz/array.h>}, there are a few static globalobjects whose definitions are provided in a compiled blitz library.  Soalways remember to include the appropriate -L flag and -lblitz on your linker command line in order to link your code against the blitz library.@cindex No match for TinyVector operators@faq{The compiler complains that there is no match for the TinyVectorunary or binary math operator I have invoked, even though I've included@code{<blitz/tinyvec.h>}.}In versions prior to blitz 0.8, the @code{tinyvec.h} header automatically included all of the blitz support for expressions involving TinyVectors.Because this code is intimately linked with the expression template support for Vector, VectorPick and other Vector-like classes, this turns out to be alarge amount of code.  The blitz Array class uses TinyVector to represent Array shapes, and thus @code{array.h} must include @code{tinyvec.h}.  This was creating a large amount of compile-time overhead, so it was decided to separate the TinyVector expression template support and put this in a newheader file @code{tinyvec-et.h}.  Therefore, your code must include @code{<blitz/tinyvec-et.h>} explicitly if it uses expressions with TinyVectors.@cindex `Array' undeclared@faq{The compiler complains that there is no Array class, even though I'veincluded @code{<blitz.h>}.}You need to have the line:@exampleusing namespace blitz;@end exampleafter including @code{<blitz.h>}.@cindex gcc memory hog@cindex memory hog, gcc@cindex out of virtual memory, gcc@cindex virtual memory problems, gcc@faq{I can't use gcc on my elderly PC because it requires @w{45--150@dmn{Mb}}to compile with Blitz++}Unfortunately this is true.  If this problem is ever fixed, itwill be by the gcc developers, so my best suggestion is to posta bug report to the gcc-bugs list.  @cindex external symbol relocation, Solaris@faq{I am using gcc under Solaris, and I get errors about ``relocation against external symbol''}This problem can be fixed by installing the gnu linker andbinutils.  Peter Nordlund found that by using  @code{gnu-binutils-2.9.1},this problem disappeared.  You can read a detailed discussion at@uref{http://oonumerics.org/blitz/support/blitz-support/archive/0029.html}.@cindex symbol too long, Solaris as@faq{I am using gcc under Solaris, and the assembler givesme an error that a symbol is too long.}This problem can also be fixed by installing the gnu linker andbinutils.  See the above question.@cindex templates with C linkage, DECcxx@faq{DECcxx reports problems about ``templates with C linkage''}This problem was caused by a problem in some versions of DECcxx's@file{math.h} header: XOPEN_SOURCE_EXTENDED was causing an@code{extern "C" @{ ... @}} section to have no closing brace.There is a kludge which is included in recent versions ofBlitz++.@cindex template instantiation resulted in an unexpected...@faq{On some platforms (especially SGI) the testsuite program@code{minsumpow} fails with the error: @code{Template instantiation resultedin an unexpected function type of...}}This is a known bug in the older versions of the EDG front end,which many C++ compilers use.  There is no known fix.Most of Blitz++ will work, but you won't be able to usesome array reductions.@section Questions about Blitz++ functionality@cindex eigenvector decomposition@cindex solving linear systems@cindex matrix inversion@cindex linear algebra@faq{For my problem, I need SVD, FFTs, QMRES, PLU, QR, ....}Blitz++ does not currently provide any of these.  However, there arenumerous C++ and C packages out there which do, and it is easy to move databack and forth between Blitz++ and other libraries.  See these terms in theindex: creating an array from pre-existing data, @code{data()},@code{stride()}, @code{extent()}, @code{fortranArray}.  For a list of othernumerical C++ libraries, see the Object Oriented Numerics Page at@uref{http://oonumerics.org/oon/}.@cindex Python@faq{Can Blitz++ be interfaced with Python?}Phil Austin has done so successfully.  See a description of his setup in @uref{http://oonumerics.org/blitz/support/blitz-support/archive/0053.html}.@cindex image processingAlso see Harry Zuzan's Python/Blitz image processing example codeat @uref{http://www.stat.duke.edu/~hz/blitz_py/index.html}.@cindex out of memory@cindex handling out of memory@cindex new handler@findex set_new_handler()@findex bad_alloc@faq{If I try to allocate an array which is too big, my program just crashesor goes into an infinite loop.  Is there some way I can handle this moreelegantly?}Blitz++ uses @code{new} to allocate memory for arrays.  In theory, yourcompiler should be throwing a @code{bad_alloc} exception when you run out ofmemory.  If it does, you can use a @code{try/catch} block to handle the out ofmemory exception.  If your compiler does not throw @code{bad_alloc}, you caninstall your own new handler to handle out of memory.Here is an excerpt from the ISO/ANSI C++ standard which describes thebehaviour of @code{new}:@itemize @bullet@item  Executes a loop: Within the loop, the function first attempts toallocate the requested storage. Whether the attempt involves a call to theStandard C library function malloc is unspecified. @item  Returns a pointer to the allocated storage if the attempt issuccessful. Otherwise, if the last argument to @code{set_new_handler()} wasa null pointer, throw @code{bad_alloc}. @item  Otherwise, the function calls the current @code{new_handler}(lib.new.handler). If the called function returns, the loop repeats. @item  The loop terminates when an attempt to allocate the requested storageis successful or when a called new_handler function does not return. @end itemizeYou can use @code{set_new_handler} to create a new handler whichwill issue an error message or throw an exception.  Forexample:@example void my_new_handler()@{cerr << "Out of memory" << endl;cerr.flush();abort();@}...// First line in main():set_new_handler(my_new_handler);@end example @cindex passing arrays by value@cindex constness problems@faq{When I pass arrays by value, the function which receivesthem can modify the array data.  Why?}It's a result of reference-counting. You have to think of array objects asbeing ``handles'' to underlying arrays. The function doesn't receive a copy ofthe array data, but rather a copy of the handle.  The alternative would beto copy the array data when passing by value, which would be grosslyinefficient.@cindex @code{<<} operator, bitshift@cindex operator @code{<<}, bitshift@cindex operator @code{>>}, bitshift@cindex @code{>>} operator, bitshift@cindex bitshift operators@faq{Why can't I use e.g.@: @code{A >> 3} to do bitshifting on arrays?}The operators @code{<<} and @code{>>} are used for input/ouput of arrays.It would cause problems with the expression templates implementation to alsouse them for bitshifting.  However, it is easy enough to define your ownbitshifting function -- see @ref{User et}.@cindex matrix multiply@faq{When I write @code{TinyMatrix * TinyVector} I get an error.}Try @code{product(d2,d1)}.  This works for matrix-matrix and matrix-vectorproducts.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -