LAPACK on Windows with Visual Studio 2010

Posted On February 11, 2011

Filed under Code+Math, CS

Comments Dropped 2 responses

Scenario: you are pulling your hair out and are about to start punching your monitor (don’t! you’ll regret it) because you found this website:
http://icl.cs.utk.edu/lapack-for-windows/lapack/,
you followed all the steps, and you are still getting love letters from your compiler / linker saying “error LNK2001 unresolved external symbol” (or something equally frustrating).

Solution: If you are not going to be solving huge matrix systems, you do not care about performance, and pre-compiled Windows versions BLAS and Lapack are sufficient for you, read on.

If you happened to follow the instructions in that Lapack link above, and managed to trick Win7 into letting you paste BLAS.lib in the Windows/System32 directory, go ahead and delete it (you don’t want junk floating around, do you?). Also, delete all the stuff you downloaded from the website. Delete the project you were trying to compile too! Start over!

  1. Download the most recent stable version of Armadillo
  2. Create an empty C++ solution in VS 2010.
  3. Create a source code file, paste the tutorial code
  4. Add extern “C” in front of the function prototypes: void dgesv_( ) —– >    extern “C” void dgesv_( )
  5. In project properties, go to Configuration Properties -> Linker -> Input
    In Additional Dependencies add lapack_win32_MT.lib;blas_win32_MT.lib;
  6. Untar your Armadillo download. Go to armadillo-1.0.2\examples\lib_win32
  7. From lib_win32 copy lapack_win32_MT.lib and .dll and blas_win32_MT.lib and .dll and paste them in the same project directory where your source (.cpp) file is.
  8. Compile, Run… (the solution is -0.661082, 9.456125, -16.014625).

Taa-dah!

Several notes:

  1. If you want to put your libraries in a separate directory and set the linker directories, go ahead. This is obviously the most basic setup.
  2. This should work with VS 2008 and Windows XP and later (32-bit). You might have problems with the pre-compiled libraries. If you happen to encounter problems and still do not want to make your own compiles of Lapack and BLAS, Armadillo website provides additional sources for the pre-compiled versions of Lapack and BLAS at the bottom of this page.

WTF is a raster image?

Posted On November 4, 2010

Filed under CS

Comments Dropped leave a response

Scenario: you do not know what “rasterize” means.
Solution: read the text below.

A raster or a bitmap is a representation of a digital image. The image is represented as bits which translate into pixels on the screen. The pixels form points of color which create a complete image.

When you rasterize an image, the image is converter into pixels. Each pixel is assigned a specific RGB color value which determines its color. The values available to express each color in RGB spectrum go from 0 to 256.

When you view a raster image, the pixels usually smooth out, and you see a photograph or a drawing. When you zoom in on the image, the pixels become apparent. Depending on resolution of the image, some raster images can be zoomed in to very large sizes, while others quickly become pixelized and difficult to see. Images with large resolution will result in large image files.

Resolution refers to the number of pixels per inch (PPI) or dots per inch (DPI) in the image. The higher the resolution, the greater the number of pixels, and the larger the size of the file. Larger number of pixels allows for a greater gradation of color and quality of image, which will translate better as the image is enlarged. For small images which do not need to be enlarged, a low DPI is sufficient.

The alternative to a rasterized image is a vector image. A vector image uses a mathematical formula to draw a picture. A vector image defines points and the paths that connect them to form a digital representation of an image. Because the mathematical formulas do not care about the size, a vector image can be enlarged and still preserve smooth edges.

However, vector images have their limitations and are most suitable for topography, line art, illustrations, and such. Raster images are the best choice for photography and shaded drawings.