| machine | author | commit | commit date | platform | time | checksum | check | rel time | bonus |
|---|
The main goal is to implement matrix "multiplication"; however, the multiplication is done over the algebra (min,+), instead the usual (+,*). The element is a 16-bit unsigned integer.
uint16_t a[L][N], b[N][M], c[L][M];
for( i = 0; i < L; ++ i)
for( j = 0; j < M; ++ j)
{
c[i][j] = 0xFFFF;
for( k = 0; k < N; ++ k)
c[i][j] = std::min( c[i][j], a[i][k] + b[k][j]);
}
template< typename policy>
class matrix {
public:
matrix(size_t m, size_t n);
size_t vsize() const;
size_t hsize() const;
uint16_t get(size_t i, size_t j) const;
void set(size_t i, size_t j, uint16_t e);
void assign_mul(const matrix & a, const matrix & b);
private: // ...
};
assign_mul assigns to this object the result of the multiplication of a and b, according to the reference algorithm above.
size - the size of the three (square) matrices - iterated through the set { 64, 128, 256, 512, 1024 }; { 64 } in Debug mode.
repeats is an auto-adjusted parameter, used to increase running time by repeatedly calling assign_mul. The range of the parameter is set so that the expected run time ranges from fractions of a second to seconds (stopped by the auto-adjustment mechanism after exceeding a second).