|
| Raster () |
|
| Raster (const Raster &other) |
|
| Raster (const Raster &other, Number value) |
| Initialize size using another raster, but use given value. More...
|
|
| Raster (Raster &&other) |
|
| Raster (Index rows, Index cols) |
|
| Raster (Index rows, Index cols, Number value) |
|
| Raster (Number *data, Index rows, Index cols) |
| Use existing data storage. More...
|
|
| Raster (std::initializer_list< std::initializer_list< Number >> l) |
|
| ~Raster () |
|
Index | cols () const |
|
Index | rows () const |
|
Number * | data () noexcept |
| Returns pointer for direct access the underlying array. More...
|
|
const Number * | data () const noexcept |
| Returns pointer for direct access the underlying array. More...
|
|
void | fill (Number value) |
|
void | zero () |
|
template<class UnaryOperation > |
void | for_each (UnaryOperation op) const |
|
const Number & | operator() (Index row, Index col) const |
|
Number & | operator() (Index row, Index col) |
|
Raster & | operator= (const Raster &other) |
|
Raster & | operator= (Raster &&other) |
|
template<typename OtherNumber > |
Raster & | operator+= (OtherNumber value) |
|
template<typename OtherNumber > |
Raster & | operator-= (OtherNumber value) |
|
template<typename OtherNumber > |
Raster & | operator*= (OtherNumber value) |
|
template<typename OtherNumber > |
Raster & | operator/= (OtherNumber value) |
|
template<typename OtherNumber > |
std::enable_if< std::is_floating_point< Number >::value||std::is_same< Number, OtherNumber >::value, Raster & >::type | operator+= (const Raster< OtherNumber > &image) |
|
template<typename OtherNumber > |
std::enable_if< std::is_floating_point< Number >::value||std::is_same< Number, OtherNumber >::value, Raster & >::type | operator-= (const Raster< OtherNumber > &image) |
|
template<typename OtherNumber > |
std::enable_if< std::is_floating_point< Number >::value||std::is_same< Number, OtherNumber >::value, Raster & >::type | operator*= (const Raster< OtherNumber > &image) |
|
template<typename OtherNumber > |
std::enable_if< std::is_floating_point< Number >::value||std::is_same< Number, OtherNumber >::value, Raster & >::type | operator/= (const Raster< OtherNumber > &image) |
|
bool | operator== (const Raster &other) const |
|
bool | operator!= (const Raster &other) const |
|
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator+ (const Raster &raster, OtherNumber value) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator- (const Raster &raster, OtherNumber value) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator* (const Raster &raster, OtherNumber value) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator/ (const Raster &raster, OtherNumber value) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator+ (OtherNumber value, const Raster &raster) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator- (OtherNumber value, const Raster &raster) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator* (OtherNumber value, const Raster &raster) |
|
template<typename OtherNumber > |
std::enable_if< std::is_arithmetic< OtherNumber >::value, Raster >::type | operator/ (OtherNumber value, const Raster &raster) |
|
Raster | pow (Raster image, double value) |
|
Raster | sqrt (Raster image) |
|
std::ostream & | operator<< (std::ostream &stream, const Raster &image) |
|
template<typename Number, typename Index = int>
class pops::Raster< Number, Index >
Representation of a raster image.
The object support raster algebra operations:
Raster<int> a = {{1, 2}, {3, 4}};
auto b = 2 * (a + 1);
The raster algebra operations sometimes overlap with matrix operations, e.g. for plus operator or multiplication by scalar. However, in some cases, the behavior is different, e.g., multiplication of the rasters results in a new raster with cell values which are result of multiplying cell values in the relevant positions of the two raster.
Raster<int> a = {{1, 2}, {3, 4}};
auto b = 2 * (a + 1);
The template parameter Number is the numerical type of the raster, typically int, float, or double.
The internal storage is directly accessible which comes with a great responsibility. Although for the computations themselves, direct access is not needed, it gives a lot of advantages when initializing the values as well as when putting them to some storage when the computation is done. The values need to be stored in one liner array with row-major oder, i.e. individual value can be accessed using the following:
row * total_number_of_columns + column
Operations involving raster and scalar preserve the type of the raster and don't produce a new type of raster based on the scalar type, i.e., a * 0.5
where a
is an integral raster type results in the same integral raster type, not floating point raster type. This makes perations such as *
and *=
behave the same for scalars.
On the other hand, operations involving two rasters of different type resolve to their common type, specifically the common type of their scalars using std::common_type
, i.e. a * b
where a
is an integral raster type and b
is a floating raster type produce a floating raster type.
The Index template parameter is an signed or unsigned integer used for indexing of rows and columns. The default value is int because signed indices is the modern C++ practice and int is used in Rcpp.
Definition at line 97 of file raster.hpp.