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

📄 arrays-globals.texi

📁 A C++ class library for scientific computing
💻 TEXI
字号:
@node Array globals@section Global functions@examplevoid                              allocateArrays(TinyVector<int,N>& shape,                                                 Array<T,N>& A,                                                  Array<T,N>& B, ...);@end example@findex allocateArrays()This function will allocate interlaced arrays, but only if interlacing isdesirable for your architecture.  This is controlled by the@code{BZ_INTERLACE_ARRAYS} flag in @file{blitz/tuning.h}.  You can provide up to11 arrays as parameters.  Any views currently associated with the arrayobjects are lost.  Here is a typical use:@exampleArray<int,2> A, B, C;allocateArrays(shape(64,64),A,B,C);@end example@cindex interlacing@cindex Array interlacingIf array interlacing is enabled, then the arrays are stored in memory likethis:  @code{A(0,0)}, @code{B(0,0)}, @code{C(0,0)}, @code{A(0,1)},@code{B(0,1)}, ...  If interlacing is disabled, then the arrays areallocated in the normal fashion: each array has its own block of memory.Once interlaced arrays are allocated, they can be used just like regulararrays.@cindex convolution, 1-D@cindex Array convolution@findex convolve()@example#include <blitz/array/convolve.h>Array<T,1>                        convolve(const Array<T,1>& B,                                            const Array<T,1>& C);@end exampleThis function computes the 1-D convolution of the arrays B and C:@tex$$ A[i] = \sum_j B[j] C[i-j] $$@end tex@htmlA[i] = sum(B[j] * C[i-j], j)@end html@ifnottex@ifnothtml@exampleA[i] = sum(B[j] * C[i-j], j)@end example@end ifnothtml@end ifnottexIf the array @math{B} has domain @math{b_l \ldots b_h}, and array @math{C}has domain @math{c_l \ldots c_h}, then the resulting array has domain@math{a_l \ldots a_h}, with @math{l = b_l + c_l} and @math{a_h = b_h + c_h}.A new array is allocated to contain the result.  To avoid copying the resultarray, you should use it as a constructor argument.  For example:@code{Array<float,1> A = convolve(B,C);} The convolution is computed in thespatial domain.  Frequency-domain transforms are not used.  If you areconvolving two large arrays, then this will be slower than using a Fouriertransform.@cindex correlation@cindex Array correlationNote that if you need a cross-correlation, you can use the convolve functionwith one of the arrays reversed.  For example:@exampleArray<float,1> A = convolve(B,C.reverse());@end exampleAutocorrelation can be performed using the same approach.@examplevoid                              cycleArrays(Array<T,N>& A, Array<T,N>& B);void                              cycleArrays(Array<T,N>& A, Array<T,N>& B,                                               Array<T,N>& C);void                              cycleArrays(Array<T,N>& A, Array<T,N>& B,                                               Array<T,N>& C, Array<T,N>& D);void                              cycleArrays(Array<T,N>& A, Array<T,N>& B,                                               Array<T,N>& C, Array<T,N>& D,                                               Array<T,N>& E);@end example @findex cycleArrays() @cindex time-steppingThese routines are useful for time-stepping PDEs.  They take a set of arrayssuch as [@code{A,B,C,D}] and cyclically rotate them to [@code{B,C,D,A}];i.e.@:  the @code{A} array then refers to what was @code{B}'s data, the@code{B} array refers to what was @code{C}'s data, and the @code{D} arrayrefers to what was @code{A}'s data.  These functions operate in constanttime, since only the handles change (i.e.@: no data is copied; only pointerschange).@examplevoid                         find(Array<TinyVector<int,Expr::rank>,1>& indices,                                  const _bz_ArrayExpr<Expr>& expr);void                         find(Array<TinyVector<int,N>,1>& indices,                                  const Array<bool,N>& exprVals);@end exampleThis is an analogue to the Matlab @code{find()} method, which takes aboolean array expression or an array of bools and returns a 1d arrayof indices for all locations where the array or expression is true.@findex find()@exampleArray<T,N>                        imag(Array<complex<T>,N>&);@end exampleThis method returns a view of the imaginary portion of the array.@findex imag()@examplevoid                              interlaceArrays(TinyVector<int,N>& shape,                                                  Array<T,N>& A,                                                   Array<T,N>& B, ...);@end exampleThis function is similar to @code{allocateArrays()} above, except that thearrays are @strong{always} interlaced, regardless of the setting of the@code{BZ_INTERLACE_ARRAYS} flag.@findex interlaceArrays() @exampleArray<T,N>                        real(Array<complex<T>,N>&);@end exampleThis method returns a view of the real portion of the array.@findex real()@exampleTinyVector<int,1>                 shape(int L);TinyVector<int,2>                 shape(int L, int M);TinyVector<int,3>                 shape(int L, int M, int N);TinyVector<int,4>                 shape(int L, int M, int N, int O);... [up to 11 dimensions]@end example@findex shape()These functions may be used to create shape parameters.  They package theset of integer arguments as a @code{TinyVector} of appropriate length.  Foran example use, see @code{allocateArrays()} above.@examplevoid                              swap(Array<T,N>& A, Array<T,N>& B);@end exampleThis function swaps the storage of two arrays, just like the @code{std::swap()}function does for STL container types.  This is a synonym for the two-argument version of @code{cycleArrays()} above.@findex swap()

⌨️ 快捷键说明

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