Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Topic Author
Posts: 64440
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

Inserting code into posts

November 27th, 2018, 8:05 pm

"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Topic Author
Posts: 64440
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

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));
 }
 }
 }
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl