|
Cellular Automata CHEM274B Group Project
Contributor(s): Chongye Feng, Emmanuel Cortes, Trevor Oldham
|
Implementation file for the utility functions utilized by CellularAutomata class defined in CAutils.h. More...
#include "CAdatatypes.h"#include <utility>#include <cmath>#include <string>#include <map>#include <sstream>#include <fstream>Functions | |
| bool | is_diagonal_neighboring_cell_2d (int i, int j) |
| determines if a cell is diagonal to the central cell diagram of slice: 1 = diagonal cell 1 0 1 0 0 0 1 0 1 More... | |
| bool | is_diagonal_neighboring_cell_3d (int i, int j, int k) |
| determines if a cell is diagonal to the central cell if k == 0 then both i and j have be non-zero diagram of slice: 1 = diagonal cell 1 0 1 0 0 0 1 0 1 More... | |
| bool | less_than_votes (const std::pair< int, int > &a, const std::pair< int, int > &b) |
| Determines if a has less votes than b. More... | |
| int | get_periodic_index (int i, int di, int axis_dim) |
| get the periodic index used for finding periodic boundary neighbors More... | |
| void | get_periodic_moore_neighbor_index (int rank, int radius, int neighborhood_array_index, int *neighbor_index) |
| Get the periodic Moore neighbor index [x, y, z] from a flattened neighborhood array index. More... | |
| void | get_periodic_von_neumann_neighbor_index (int rank, int radius, int neighborhood_array_index, int *neighbor_index) |
| Get the periodic Von Neumann neighbor index [x, y, z] from a flattened neighborhood array index. More... | |
| void | get_density (std::ifstream &data, std::ofstream &result) |
| Get the density result output to the result file. More... | |
Implementation file for the utility functions utilized by CellularAutomata class defined in CAutils.h.
Contributor(s)
Chongye Feng
| void get_density | ( | std::ifstream & | data, |
| std::ofstream & | result | ||
| ) |
Get the density result output to the result file.
| data | |
| result | Line1 n_states; Line2 dims; Line3 counts of states of each step. |
| int get_periodic_index | ( | int | i, |
| int | di, | ||
| int | axis_dim | ||
| ) |
get the periodic index used for finding periodic boundary neighbors
| i | cell's i-th index |
| di | neighbor's cell i-th offset |
| axis_dim | dimension of i-th axis |
| void get_periodic_moore_neighbor_index | ( | int | rank, |
| int | radius, | ||
| int | neighborhood_array_index, | ||
| int * | neighbor_index | ||
| ) |
Get the periodic Moore neighbor index [x, y, z] from a flattened neighborhood array index.
| rank | cell data rank |
| radius | neighborhood radius |
| neighborhood_array_index | flat array index to be converted to [x, y, z] |
| neighbor_index | int array containing x, y and z coordinates |
| void get_periodic_von_neumann_neighbor_index | ( | int | rank, |
| int | radius, | ||
| int | neighborhood_array_index, | ||
| int * | neighbor_index | ||
| ) |
Get the periodic Von Neumann neighbor index [x, y, z] from a flattened neighborhood array index.
| rank | cell data rank |
| radius | neighborhood radius |
| neighborhood_array_index | flat array index to be converted to [x, y, z] |
| neighbor_index | int array containing x, y and z coordinates |
| bool is_diagonal_neighboring_cell_2d | ( | int | i, |
| int | j | ||
| ) |
determines if a cell is diagonal to the central cell
diagram of slice: 1 = diagonal cell
1 0 1
0 0 0
1 0 1
| i | cell's i-th index |
| j | cell's j-th index |
| bool is_diagonal_neighboring_cell_3d | ( | int | i, |
| int | j, | ||
| int | k | ||
| ) |
determines if a cell is diagonal to the central cell
if k == 0 then both i and j have be non-zero
diagram of slice: 1 = diagonal cell
1 0 1
0 0 0
1 0 1
if k != 0 then either i or j can be non-zero
diagram of slice: 1 = diagonal cell
1 1 1
1 0 1
1 1 1
| i | cell's i-th index |
| j | cell's j-th index |
| k | cell's k-th index |
| bool less_than_votes | ( | const std::pair< int, int > & | a, |
| const std::pair< int, int > & | b | ||
| ) |
Determines if a has less votes than b.
Used to determine max element in a MajorityCounter instance.
| a | pair instance with the votes stored in the second property |
| b | other pair with the votes stored in the second property |