| Cellular Automata CHEM274B Group Project
    Contributor(s): Chongye Feng, Emmanuel Cortes, Trevor Oldham | 
This header files contains utility functions used by CellularAutomata class. More...
#include <utility>#include <fstream>Go to the source code of this file.
| Functions | |
| template<typename T > | |
| void | swap_states (T *vector, T *next_vector, int axis1_dim) | 
| swaps the computed next_vector to the current vector  More... | |
| template<typename T > | |
| void | swap_states (T **matrix, T **next_matrix, int axis1_dim, int axis2_dim) | 
| swaps the computed next_matrix to the current matrix  More... | |
| template<typename T > | |
| void | swap_states (T ***tensor, T ***next_tensor, int axis1_dim, int axis2_dim, int axis3_dim) | 
| swaps the computed next_tensor to the current tensor  More... | |
| 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... | |
This header files contains utility functions used by CellularAutomata class.
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 | 
| void swap_states | ( | T *** | tensor, | 
| T *** | next_tensor, | ||
| int | axis1_dim, | ||
| int | axis2_dim, | ||
| int | axis3_dim | ||
| ) | 
swaps the computed next_tensor to the current tensor
| tensor | cellular automata current tensor state | 
| next_tensor | cellular automata next tensor state | 
| axis1_dim | first tensor dimension | 
| axis2_dim | second tensor dimension | 
| axis3_dim | third tensor dimension | 
| void swap_states | ( | T ** | matrix, | 
| T ** | next_matrix, | ||
| int | axis1_dim, | ||
| int | axis2_dim | ||
| ) | 
swaps the computed next_matrix to the current matrix
| matrix | cellular automata current matrix state | 
| next_matrix | cellular automata next matrix state | 
| axis1_dim | first matrix dimension | 
| axis2_dim | second matrix dimension | 
| void swap_states | ( | T * | vector, | 
| T * | next_vector, | ||
| int | axis1_dim | ||
| ) | 
swaps the computed next_vector to the current vector
| vector | cellular automata current vector state | 
| next_vector | cellular automata next vector state | 
| axis1_dim | vector dimension |