HighMap library (C++)
Loading...
Searching...
No Matches
hmap::InteractionMatrix Struct Reference

Generic S x S matrix representing pair-wise interaction properties between species. More...

#include <forest_growth.hpp>

Collaboration diagram for hmap::InteractionMatrix:

Public Member Functions

 InteractionMatrix ()=default
 InteractionMatrix (size_t num_species, float default_val=0.0f)
 Constructs an InteractionMatrix of size num_species x num_species.
void fill (float value)
 Fills the entire matrix with a constant value.
float get (size_t s1, size_t s2) const
 Gets the value at entry (s1, s2).
void set (size_t s1, size_t s2, float value)
 Sets the value at entry (s1, s2).
void set_symmetric (size_t s1, size_t s2, float value)
 Sets symmetric values at (s1, s2) and (s2, s1).

Static Public Member Functions

static InteractionMatrix diagonal (const std::vector< float > &diag, float off_diag_val=0.0f)
 Creates a matrix with specified diagonal values and constant off-diagonal values.
static InteractionMatrix from_radii (const std::vector< float > &radii, float multiplier=2.0f)
 Creates an interaction matrix computed from individual species radii.
static InteractionMatrix from_species (const std::vector< Species > &species, float multiplier=2.0f)
 Creates an interaction matrix computed from Species definitions.
static InteractionMatrix random (size_t num_species, uint32_t seed, float random_offset=0.1f, bool symmetric=true)
 Creates a matrix initialized with random values perturbed around 1.0.
static InteractionMatrix uniform (size_t num_species, float val)
 Creates a matrix initialized to a uniform value.

Public Attributes

size_t size = 0
 Number of species (matrix dimension).
std::vector< float > values = {}
 Row-major matrix elements.

Detailed Description

Generic S x S matrix representing pair-wise interaction properties between species.

Constructor & Destructor Documentation

◆ InteractionMatrix() [1/2]

hmap::InteractionMatrix::InteractionMatrix ( )
default

◆ InteractionMatrix() [2/2]

hmap::InteractionMatrix::InteractionMatrix ( size_t num_species,
float default_val = 0.0f )
explicit

Constructs an InteractionMatrix of size num_species x num_species.

Parameters
num_speciesNumber of species.
default_valInitial value for all elements.

Member Function Documentation

◆ fill()

void hmap::InteractionMatrix::fill ( float value)

Fills the entire matrix with a constant value.

Parameters
valueValue to fill.

◆ get()

float hmap::InteractionMatrix::get ( size_t s1,
size_t s2 ) const

Gets the value at entry (s1, s2).

Parameters
s1Row species index.
s2Column species index.
Returns
float Matrix value.

◆ set()

void hmap::InteractionMatrix::set ( size_t s1,
size_t s2,
float value )

Sets the value at entry (s1, s2).

Parameters
s1Row species index.
s2Column species index.
valueMatrix value.

◆ set_symmetric()

void hmap::InteractionMatrix::set_symmetric ( size_t s1,
size_t s2,
float value )

Sets symmetric values at (s1, s2) and (s2, s1).

Parameters
s1First species index.
s2Second species index.
valueMatrix value.

◆ diagonal()

InteractionMatrix hmap::InteractionMatrix::diagonal ( const std::vector< float > & diag,
float off_diag_val = 0.0f )
static

Creates a matrix with specified diagonal values and constant off-diagonal values.

Parameters
diagVector of diagonal elements.
off_diag_valOff-diagonal value.
Returns
InteractionMatrix Resulting matrix.

◆ from_radii()

InteractionMatrix hmap::InteractionMatrix::from_radii ( const std::vector< float > & radii,
float multiplier = 2.0f )
static

Creates an interaction matrix computed from individual species radii.

Each entry (s1, s2) is set to multiplier * (radii[s1] + radii[s2]).

Parameters
radiiVector of species radii.
multiplierScaling factor applied to the sum of radii (defaults to 2.0f).
Returns
InteractionMatrix Resulting matrix.

◆ from_species()

InteractionMatrix hmap::InteractionMatrix::from_species ( const std::vector< Species > & species,
float multiplier = 2.0f )
static

Creates an interaction matrix computed from Species definitions.

Each entry (s1, s2) is set to multiplier * (species[s1].radius + species[s2].radius).

Parameters
speciesVector of Species definitions.
multiplierScaling factor applied to the sum of radii (defaults to 2.0f).
Returns
InteractionMatrix Resulting matrix.

◆ random()

InteractionMatrix hmap::InteractionMatrix::random ( size_t num_species,
uint32_t seed,
float random_offset = 0.1f,
bool symmetric = true )
static

Creates a matrix initialized with random values perturbed around 1.0.

Each entry is sampled uniformly in [1.0 - random_offset, 1.0 + random_offset].

Parameters
num_speciesNumber of species.
seedRandom seed.
random_offsetMaximum random variation relative to 1.0.
symmetricWhether to enforce symmetric values (A_ij = A_ji).
Returns
InteractionMatrix Resulting matrix.

◆ uniform()

InteractionMatrix hmap::InteractionMatrix::uniform ( size_t num_species,
float val )
static

Creates a matrix initialized to a uniform value.

Parameters
num_speciesNumber of species.
valUniform value.
Returns
InteractionMatrix Resulting matrix.

Member Data Documentation

◆ size

size_t hmap::InteractionMatrix::size = 0

Number of species (matrix dimension).

◆ values

std::vector<float> hmap::InteractionMatrix::values = {}

Row-major matrix elements.


The documentation for this struct was generated from the following files: