Since the new release of CUDA v5.5 the integration with VS2012 became super-easy. All you have to do is to download the installer from here and run it. The magic is done behind the scenes and user can almost immediately start using capabilities of GPU in his programs.

Firstly, in your project's build customization you have to specify to use CUDA v5.5:

buildCustomiz

Build Customization

 

 

Then, you have to add include and library directories project's properties:

buildCustomiz2

Project Properties - Setting Directories

And finally, you have to change the compiler flags for CUDA if necessary, e.g. the architecture:

buildCustomiz3

Changing CUDA compiler flags

 

After this few simple steps you should be able to use CUDA libraries in your code.

Tags: ,

When using Linux systems most of the times the Boost libraries are installed and no further action is required in order to use them. On the other hand, Windows users have to download the source from boost website and compile it by themselves.

Many of you asked me how should the Boost libraries be installed on Windows machine, so here is a quick tutorial (there are many websites discussing it but it's nice to have it in one place).

  1. First of all you should have VS 2012 installed with the latest updates.
  2. Download the latest boost source code here and unzip it somewhere, e.g. C:\boost.
  3. Now run the VS2012 x64 native tools command prompt.
  4. Change your current directory to the place where you unzipped boost, e.g. "cd C:\boost" .
  5. Run "bootstrap.bat" script.
  6. Run "bjam.exe" executable.
  7. After several minutes you should receive a message that the compilation was successful.
  8. All you need to do now is to add "C:\boost" to compiler include paths and "C:\boost\stage\lib" to linker library path of your project.
  9. You are ready to go!

 

Tags: ,

Journey

The beginning of a thousand-mile journey begins with a single step. (more)

Julia

Interesting project.. Julia!

The benchmark table (for more info visit the homepage of the project):

julia

Tags:

Science And Python

This is an interesting video where Fernando Pérez talks about uses of Python in science. He covers many topics like Matplotlib, NumPy, SciPy, Cython, IPython, wrappers for R, etc. I highly recommend watching it!

 

Tags: , , , ,

One of my friends is reading this book and encountered a problem when he tried to separate the definition from declaration of a template class.

To illustrate this assume we have this header file, foo.h, with declaration of template class Foo:

template<typename T>
class Foo {
public:
  Foo();
  void someMethod(T x);
private:
  T x;
};

, with the following definition of member functions in separate file foo.cpp:

template<typename T>
Foo<T>::Foo()
{
  ...
}

template<typename T>
void Foo<T>::someMethod(T x)
{
  ...
}

Now, if you try to use this template class and instantiate T to be actually a double or int, then the compiler will throw an error, that it doesn't recognize Foo<double>::Foo() or Foo<int>::Foo(). Problem is when processing Foo.cpp compiler would see template definition and when processing our new .cpp file it would see Foo<int>.

There are more solutions to this problem. One is to put this line at the end of header file Foo.h:

#include "Foo.cpp"

And the other one is to put explicit instantiations into the Foo.cpp file:

template class Foo<int>;
template class Foo<double>;

None of these solutions is perfect but I prefer the first one just because you are not limited just to those instantiations you put into .cpp file in the second solution.

You can find more on this here, here and here.

Tags: , , ,

If you are having errors when saving text into your MySQL database like:

UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in position 3832: ordinal not in range(256),

you should make sure your database and tables are set to UTF-8 and when connecting to the database you should specify the charset as well:

connect(host, user, password, dbname, charset='utf8')

 

 

Tags: , , ,

A friend of mine was submitting some information on one of Bloomberg's websites and sent me this screenshot:

Bloomberg

It's 2012 and not pre 1991..

Tags:

I read the details about non-farm payrolls and other employment statistics number on BLS website and I found an interesting number. This is the quote from the site:

 

 For example, the confidence interval for the monthly change in
total nonfarm employment from the establishment survey is on the order
of plus or minus 100,000. Suppose the estimate of nonfarm employment
increases by 50,000 from one month to the next. The 90-percent confidence
interval on the monthly change would range from -50,000 to +150,000 
(50,000 +/- 100,000).

 

Which means that for the latest number which was 114,00, the true value is in interval 14,000 to 214,000 with 90% probability. Is it reliable? But even though the markets reacts so heavily on even a small deviation from expectations..

Tags: , ,

Some of my colleagues didn't know that you can use mathematical constants that are part of "cmath". Here is the small snippet that shows how to use PI from cmath library. Be aware that you need to write "#define _USE_MATH_DEFINES" before you include cmath.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
#define _USE_MATH_DEFINES
 
#include 
#include 
 
using namespace std;
 
int main() {
 
  cout &lt;&lt; M_PI &lt;&lt; endl;
 
  return 0;
}

 

The full list of constants is:

 

Symbol Expression Value
M_E e 2.71828182845904523536
M_LOG2E log2(e) 1.44269504088896340736
M_LOG10E log10(e) 0.434294481903251827651
M_LN2 ln(2) 0.693147180559945309417
M_LN10 ln(10) 2.30258509299404568402
M_PI pi 3.14159265358979323846
M_PI_2 pi/2 1.57079632679489661923
M_PI_4 pi/4 0.785398163397448309616
M_1_PI 1/pi 0.318309886183790671538
M_2_PI 2/pi 0.636619772367581343076
M_2_SQRTPI 2/sqrt(pi) 1.12837916709551257390
M_SQRT2 sqrt(2) 1.41421356237309504880
M_SQRT1_2 1/sqrt(2) 0.707106781186547524401

Tags: ,

« Older entries