Kronecker product based fractals: Difference between revisions
Content deleted Content added
C++ - added links to output images |
m Minor edit to C++ code |
||
Line 314: | Line 314: | ||
for (const auto& row : values) { |
for (const auto& row : values) { |
||
assert(row.size() <= columns_); |
assert(row.size() <= columns_); |
||
std::copy(begin(row), end(row), |
std::copy(begin(row), end(row), &elements_[columns_ * i++]); |
||
} |
} |
||
} |
} |
||
size_t rows() const { return rows_; } |
size_t rows() const { return rows_; } |
||
size_t columns() const { return columns_; } |
size_t columns() const { return columns_; } |
||
scalar_type |
const scalar_type& operator()(size_t row, size_t column) const { |
||
assert(row < rows_); |
assert(row < rows_); |
||
assert(column < columns_); |
|||
⚫ | |||
} |
} |
||
scalar_type& operator()(size_t row, size_t column) { |
|||
assert(row < rows_); |
assert(row < rows_); |
||
⚫ | |||
} |
|||
const scalar_type& at(size_t row, size_t column) const { |
|||
assert(column < columns_); |
assert(column < columns_); |
||
return |
return elements_[row * columns_ + column]; |
||
} |
|||
scalar_type& at(size_t row, size_t column) { |
|||
assert(column < columns_); |
|||
return row_data(row)[column]; |
|||
} |
} |
||
private: |
private: |
||
Line 352: | Line 347: | ||
size_t columns = acolumns * bcolumns; |
size_t columns = acolumns * bcolumns; |
||
matrix<scalar_type> c(rows, columns); |
matrix<scalar_type> c(rows, columns); |
||
for (size_t i = 0; i < rows; ++i) |
for (size_t i = 0; i < rows; ++i) |
||
auto* crow = c.row_data(i); |
|||
auto* arow = a.row_data(i/brows); |
|||
auto* brow = b.row_data(i % brows); |
|||
for (size_t j = 0; j < columns; ++j) |
for (size_t j = 0; j < columns; ++j) |
||
c(i, j) = a(i/brows, j/bcolumns) * b(i % brows, j % bcolumns); |
|||
} |
|||
return c; |
return c; |
||
} |
} |
||
Line 373: | Line 364: | ||
for (size_t i = 0; i < height; ++i) |
for (size_t i = 0; i < height; ++i) |
||
for (size_t j = 0; j < width; ++j) |
|||
imageData[i * bytesPerLine + j] = result(i, j); |
|||
QImage image(&imageData[0], width, height, bytesPerLine, QImage::Format_Indexed8); |
QImage image(&imageData[0], width, height, bytesPerLine, QImage::Format_Indexed8); |