@Author: armylau
@Date: 2004-8-12
One. cause
When installing and using Blitz , I often encountered the "VC _net 2003 - installation and use Boost 1_30 and Blitz 0_6" written by CCBOY, but the official document of Blitz is not clear, I have to come. I spent a lot of time before I first figured out.
two. Introduction to Blitz
Everyone knows that Fortran is a recognized scientific computing programming language, and a large number of numerical calculations are based on Fortran, such as lapack. And Blitz provides scientific computing personnel to the object-oriented C numerical computing library, speed can match Fortran77 / 90 .
People who have used Matlab know that MATLAB is a matrix-based fourth-generation language that treats each variable as a matrix, which is assigned compared to mainstream languages such as C / C / Java, and BLITZ also provides The powerful operation of this matrix, and the performance is much faster than MATLAB, because the two language characteristics are determined.
An array and vector (ie matrix), random number generator, small vector, and matrix are available in the latest version of the Blitz .
It is worth noting that BLITZ is very personally compared to other numerical computing packages, it does not seek high, if it does not provide all matrix operation functions, as specifically vector, FFT analysis, etc. It is characterized by Object-Oriented, Array Operation Syntax and Template Action (But The Main Focus Of Blitz IS ON Array Syntax and Stencil Operations) [4]. Matrix operation function, think of VALARRY in STL? The features in Valarray are all achieved and strengthened. This can be initially displayed in the test item MT1.
three. Installation and test
1) Install BLITZ - 0.7 Universal Code
First install the most original code package, the source code is a cross-platform, as long as BLITZ support.
On http://www.oonumerics.org/blitz / only 0.6, the latest version is 0.7, at http://sourceforge.net/project/showfiles.php?group_id=63961. Unzip, such as C : / VC / BLITZ - 0.7 /
2) Install BLITZ-VS.NET1.5 -for VS.Net2003 Project
If you want BLITZ to be used under VS.NET, you will define the corresponding macro, use the class provided by the corresponding header file, lib, and blitz . And the macro definition, the LIB compile project file, these work Julian Cummins have been Ok. View Supported Platforms on the BLITZ home page, see the blitz for vs.net, click on Blitz to look for the SourceForge CVS, http://cvs.source.net/viewcvs.py/blitz in the cvs directory / blitz, download two files: blitz-vs.net.zip and readme-vs.net.txt, the latest version of these two files when I download is 1.6 and 1.1
Unzip BLITZ-VS.NET ZIP, the main directory of C: / VC / BLITZ - 0.7, we assume that it is C: /VC / BLITZ-VS.NET1.6, the directory structure is as follows:
BLITZ /
Blitz-TestSuite /
Blitz-Library.ncb
Blitz-Library.sln
Blitz-Library.suo
Blitz / inside is config.h, which defines BliTz-related macro variables, such as bz_have_complex, bz_have_stl, etc. This is necessary for each item.
There is also a VC project file in the blitz directory. This project is used to generate the blitz.lib file. We will mention how to set it up later.
3) Generate blitz.lib
Start VS.NET2003, Settings: Tools -> Options -> Project -> VC Directory, add BLITZ-0.7 path (i.e., / I parameters in CL), such as C: / Vc / Blitz. The picture below is my configuration
Using VS.NET 2003 to open to c: /vc/blitz.vcproj, as mentioned above, we are using this project to generate blitz.lib. The source file it use is Blitz -0.7 / src / globals.cpp, because the code original author is in order to keep the code's unique copy, there is no compression package that is to this for vs.net, you have to copy the src directory of the original Blitz directory to here. Such as C: / vc / blitz - 0.7 / src copy to C: /VC / BLITZ-VS.NET1.6/SRC
Compilation Generate BLITZ.LIB. Error prompts when compile, such as Error PRJ0019: Tools from "Copying Blitz_d.lib .." doesn't matter, this is Blitz's bug, in the debug or release directory has generated the files we need. The Debug version is blitz_d.lib, the release version is blitz.lib.
At this point, this lib file can be used for future versions, we can configure global options:
First create a lib directory under /Blitz-vs.net1.6/, copy BLITZ.LIB and BLITZ_D.LIB. In Tools -> Options -> Project -> VC Directory -> Library File Add We LIB Path
4) Compile and test Blitz-Testsuit
Open Blitz-Library.sln with VS.NET2003, including 54 test cases.
Copy the TestSuite directory under Blitz - 0.7 to Blitz-vs.Net1.6, which is also to maintain the uniqueness of the code, according to the author said [4].
To confirm this, you can open the project profile vsproj, open with a text editor such as Notepad, view
Name = "Source Files"
Filter = "CPP; C; CXX; DEF; ODL; IDL; HPJ; BAT; ASM">
RELATIVEPATH = "../../ TestSuite / Ctors.cpp">
Determine the project option Enter the library
BLITZ_D.LIB
or
Blitz.lib
Compile, execute.
1) If testing ABA1, this is a test of the maximum value of the group
Source code is:
#include
BZ_USING_NAMESPACE (Blitz)
int main ()
{
Array
Psielem =
-0.121990517304243, -0.099118834514638, -0.164750336116265;
Double psi_max = blitz :: Max (psielem);
COUT << "psielem =" << psielem << endl;
COUT << "psi_max =" << psi_max << Endl;
}
The result is:
Psielem = 3
[-0.121991 -0.0991188 -0.16475]
PSI_MAX = -0.0991188
2) Test MT1 - The main test matrix assignment and operation syntax, INDEX usage, etc.
Source code:
#include
BZ_USING_NAMESPACE (Blitz)
#if 0
BZ_Declare_stencil2 (Kinenergy, A, B)
B = laplacian3d (a);
BZ_END_STENCIL_WITH_SHAPE (SHAPE (-1, -1, -1), Shape (1, 1, 1)) Typedef Complex
Typedef Array
Array3D;
int main ()
{
Const int n = 5;
Array3D A (n, n, n);
Array3D B (n, n, n);
// Fill A Three-Dimensional Array with a Gaussian Function
FirstIndex i;
SECONDEX J;
ThirdIndex K;
FLOAT MIDPOINT = 15/2 .;
Float C = - 1 / 3.0;
A = Exp (C * (SQR (I-MIDPOINT) SQR (J-Midpoint)
SQR (K-MIDPOINT))));
ApplyStencil (Kinenergy (), A, B);
Array
OUT_VIEW (B.Data (), Shape (n * n * n));
Cout << OUT_VIEW;
}
#ENDIF
BZ_Declare_stencil2 (Footprint, A, B)
B = laplacian2d4 (a);
BZ_END_STENCIL_WITH_SHAPE (SHAPE (-2, -2), Shape ( 2, 2))
int main ()
{
INT n = 9;
Array
A = 0;
A (4, 4) = 1;
ApplyStencil (Footprint (), A, B);
Cout << b (Range (2, 6), Range (2, 6)) << ENDL;
}
The result is:
5 x 5
[0 0 -1 0 0
0 0 16 0 0
-1 16 -60 16 -1
0 0 16 0 0
0 0 -1 0 0]
Fives. Use in their own project
A simple example,
After the new personal project, pay attention to the following things:
1. Added the path to the LIB or the path to the LIB: Copy BLITZ.LIB to the project or configure the reference path in the project properties.
2. Add config.h to copy the original macro definition file that we compile BLITZ.LIB.
3. Used Using Namespace Blitz
4. Use the library object of BLITZ correctly
#include "stdafx.h"
#include "config.h"
#include
#include
Using Namespace Blitz;
int main ()
{
Complex
COUT << c << endl;
Array
Ar = 1, 1,
2, 2;
COUT << ar << endl;
}
When compiling, all kinds of configurations should be very careful. If you are not careful, you will be wrong. Step by step by step, you should not have too big errors, there is any questions or suggestions, you can contact me Armyllau @ 163. COM
six. references:
1. [blitz] Blitz official homepage, document
2. [IBM] C and C matrix library - Evaluation and comparison Meschach, Cooperware Matrix and Blitz.htm http://www-900.ibm.com/DeveloperWorks/cn/linux/other/matrix/index.shtml3. [ CCBOY] CCBOY written VC _net 2003 - Install and use Boost 1_30 and Blitz 0_6
4. [Julian C.] emails