Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Inserting code into posts

November 27th, 2018, 8:05 pm

 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Inserting code into posts

November 27th, 2018, 8:06 pm

Just like that, not like that
ublas::matrix<W> d = ...
 std::size_t n = ...

 for (std::size_t v = 0; v < n; ++v)
 {
 d(v, v) = 0.0;
 }

 for (std::size_t k = 0; k < n; ++k)
 {
 for (std::size_t i = 0; i < n; ++i)
 {
 for (std::size_t j = 0; j < n; ++j)
 {
 d(i, j) = std::min<W>(d(i, j), d(i, k) + d(k,j));
 }
 }
 }