Gemmi C++ API
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
gemmi::Grid< T > Struct Template Reference

Real-space grid. More...

#include <grid.hpp>

Inheritance diagram for gemmi::Grid< T >:
[legend]

Public Types

using Point = typename GridBase< T >::Point
 
- Public Types inherited from gemmi::GridBase< T >
using Tsum = typename std::conditional< std::is_integral< T >::value, std::ptrdiff_t, T >::type
 

Public Member Functions

void copy_metadata_from (const GridMeta &g)
 copy unit_cell, spacegroup, nu, nv, nw, axis_order and set spacing
 
void calculate_spacing ()
 set spacing and orth_n
 
double min_spacing () const
 
void set_size_without_checking (int nu_, int nv_, int nw_)
 
void set_size (int nu_, int nv_, int nw_)
 
void set_size_from_spacing (double approx_spacing, GridSizeRounding rounding)
 
void set_unit_cell (double a, double b, double c, double alpha, double beta, double gamma)
 
void set_unit_cell (const UnitCell &cell)
 
template<typename S >
void setup_from (const S &st, double approx_spacing)
 
size_t index_s (int u, int v, int w) const
 Returns index in data array for (u,v,w). Safe but slower than index_q().
 
T get_value (int u, int v, int w) const
 returns data[index_s(u, v, w)]
 
void set_value (int u, int v, int w, T x)
 
Point get_point (int u, int v, int w)
 Point stores normalizes indices (not the original u,v,w).
 
Point get_nearest_point (const Fractional &f)
 
Point get_nearest_point (const Position &pos)
 
size_t get_nearest_index (const Fractional &f)
 
Fractional point_to_fractional (const Point &p) const
 Point stores normalized indices, so fractional coordinates are in [0,1).
 
Position point_to_position (const Point &p) const
 
T interpolate_value (double x, double y, double z) const
 https://en.wikipedia.org/wiki/Trilinear_interpolation x,y,z are grid coordinates (x=1.5 is between 2nd and 3rd grid point).
 
T interpolate_value (const Fractional &fctr) const
 
T interpolate_value (const Position &ctr) const
 
double tricubic_interpolation (double x, double y, double z) const
 https://en.wikipedia.org/wiki/Tricubic_interpolation x,y,z are grid coordinates (x=1.5 is between 2nd and 3rd grid point).
 
double tricubic_interpolation (const Fractional &fctr) const
 
double tricubic_interpolation (const Position &ctr) const
 
std::array< double, 4 > tricubic_interpolation_der (double x, double y, double z) const
 returns the same as above + derivatives df/dx, df/dy, df/dz
 
std::array< double, 4 > tricubic_interpolation_der (const Fractional &fctr) const
 
T interpolate (const Fractional &f, int order) const
 
void get_subarray (T *dest, std::array< int, 3 > start, std::array< int, 3 > shape) const
 
void set_subarray (const T *src, std::array< int, 3 > start, std::array< int, 3 > shape)
 
template<bool UsePbc>
void check_size_for_points_in_box (int &du, int &dv, int &dw, bool fail_on_too_large_radius) const
 
template<bool UsePbc, typename Func >
void do_use_points_in_box (const Fractional &fctr, int du, int dv, int dw, Func &&func, double radius=INFINITY)
 
template<bool UsePbc, typename Func >
void use_points_in_box (const Fractional &fctr, int du, int dv, int dw, Func &&func, bool fail_on_too_large_radius=true, double radius=INFINITY)
 
template<bool UsePbc, typename Func >
void use_points_around (const Fractional &fctr, double radius, Func &&func, bool fail_on_too_large_radius=true)
 
void set_points_around (const Position &ctr, double radius, T value, bool use_pbc=true)
 
void change_values (T old_value, T new_value)
 
template<typename Func >
void symmetrize (Func func)
 Use.
 
template<typename Func >
void symmetrize_using_ops (const std::vector< GridOp > &ops, Func func)
 
void symmetrize_min ()
 
void symmetrize_max ()
 
void symmetrize_abs_max ()
 
void symmetrize_sum ()
 multiplies grid points on special position
 
void symmetrize_nondefault (T default_)
 
void symmetrize_avg ()
 
void normalize ()
 scale the data to get mean == 0 and rmsd == 1 (doesn't work for T=complex)
 
void resample_to (Grid< T > &dest, int order) const
 
- Public Member Functions inherited from gemmi::GridBase< T >
void check_not_empty () const
 
void set_size_without_checking (int nu_, int nv_, int nw_)
 
T get_value_q (int u, int v, int w) const
 
size_t point_to_index (const Point &p) const
 
Point index_to_point (size_t idx)
 
void fill (T value)
 
Tsum sum () const
 
iterator begin ()
 
iterator end ()
 
- Public Member Functions inherited from gemmi::GridMeta
size_t point_count () const
 
Fractional get_fractional (int u, int v, int w) const
 u,v,w are not normalized here
 
Position get_position (int u, int v, int w) const
 
std::vector< GridOpget_scaled_ops_except_id () const
 
size_t index_q (int u, int v, int w) const
 Quick(est) index function, but works only if 0 <= u < nu, etc.
 
size_t index_n (int u, int v, int w) const
 Faster than index_s(), but works only if -nu <= u < 2*nu, etc.
 
size_t index_n_ref (int &u, int &v, int &w) const
 The same as index_n(), but modifies arguments.
 
size_t index_near_zero (int u, int v, int w) const
 Faster than index_n(), but works only if -nu <= u < nu, etc.
 

Static Public Member Functions

static double grid_modulo (double x, int n, int *iptr)
 

Public Attributes

double spacing [3] = {0., 0., 0.}
 spacing between virtual planes, not between points
 
UpperTriangularMat33 orth_n
 unit_cell.orth.mat columns divided by nu, nv, nw
 
- Public Attributes inherited from gemmi::GridBase< T >
std::vector< Tdata
 
- Public Attributes inherited from gemmi::GridMeta
UnitCell unit_cell
 
const SpaceGroupspacegroup = nullptr
 
int nu = 0
 
int nv = 0
 
int nw = 0
 
AxisOrder axis_order = AxisOrder::Unknown
 

Detailed Description

template<typename T = float>
struct gemmi::Grid< T >

Real-space grid.

For simplicity, some operations work only if the grid covers whole unit cell and axes u,v,w correspond to a,b,c in the unit cell.

Definition at line 302 of file grid.hpp.

Member Typedef Documentation

◆ Point

template<typename T = float>
using gemmi::Grid< T >::Point = typename GridBase<T>::Point

Definition at line 303 of file grid.hpp.

Member Function Documentation

◆ copy_metadata_from()

template<typename T = float>
void gemmi::Grid< T >::copy_metadata_from ( const GridMeta g)
inline

copy unit_cell, spacegroup, nu, nv, nw, axis_order and set spacing

Definition at line 317 of file grid.hpp.

◆ calculate_spacing()

template<typename T = float>
void gemmi::Grid< T >::calculate_spacing ( )
inline

set spacing and orth_n

Definition at line 328 of file grid.hpp.

◆ min_spacing()

template<typename T = float>
double gemmi::Grid< T >::min_spacing ( ) const
inline

Definition at line 338 of file grid.hpp.

◆ set_size_without_checking()

template<typename T = float>
void gemmi::Grid< T >::set_size_without_checking ( int  nu_,
int  nv_,
int  nw_ 
)
inline

Definition at line 342 of file grid.hpp.

◆ set_size()

template<typename T = float>
void gemmi::Grid< T >::set_size ( int  nu_,
int  nv_,
int  nw_ 
)
inline

Definition at line 348 of file grid.hpp.

◆ set_size_from_spacing()

template<typename T = float>
void gemmi::Grid< T >::set_size_from_spacing ( double  approx_spacing,
GridSizeRounding  rounding 
)
inline

Definition at line 353 of file grid.hpp.

◆ set_unit_cell() [1/2]

template<typename T = float>
void gemmi::Grid< T >::set_unit_cell ( double  a,
double  b,
double  c,
double  alpha,
double  beta,
double  gamma 
)
inline

Definition at line 361 of file grid.hpp.

◆ set_unit_cell() [2/2]

template<typename T = float>
void gemmi::Grid< T >::set_unit_cell ( const UnitCell cell)
inline

Definition at line 367 of file grid.hpp.

◆ setup_from()

template<typename T = float>
template<typename S >
void gemmi::Grid< T >::setup_from ( const S st,
double  approx_spacing 
)
inline

Definition at line 373 of file grid.hpp.

◆ index_s()

template<typename T = float>
size_t gemmi::Grid< T >::index_s ( int  u,
int  v,
int  w 
) const
inline

Returns index in data array for (u,v,w). Safe but slower than index_q().

Definition at line 380 of file grid.hpp.

◆ get_value()

template<typename T = float>
T gemmi::Grid< T >::get_value ( int  u,
int  v,
int  w 
) const
inline

returns data[index_s(u, v, w)]

Definition at line 386 of file grid.hpp.

◆ set_value()

template<typename T = float>
void gemmi::Grid< T >::set_value ( int  u,
int  v,
int  w,
T  x 
)
inline

Definition at line 390 of file grid.hpp.

◆ get_point()

template<typename T = float>
Point gemmi::Grid< T >::get_point ( int  u,
int  v,
int  w 
)
inline

Point stores normalizes indices (not the original u,v,w).

Definition at line 395 of file grid.hpp.

◆ get_nearest_point() [1/2]

template<typename T = float>
Point gemmi::Grid< T >::get_nearest_point ( const Fractional f)
inline

Definition at line 402 of file grid.hpp.

◆ get_nearest_point() [2/2]

template<typename T = float>
Point gemmi::Grid< T >::get_nearest_point ( const Position pos)
inline

Definition at line 407 of file grid.hpp.

◆ get_nearest_index()

template<typename T = float>
size_t gemmi::Grid< T >::get_nearest_index ( const Fractional f)
inline

Definition at line 411 of file grid.hpp.

◆ point_to_fractional()

template<typename T = float>
Fractional gemmi::Grid< T >::point_to_fractional ( const Point p) const
inline

Point stores normalized indices, so fractional coordinates are in [0,1).

Definition at line 416 of file grid.hpp.

◆ point_to_position()

template<typename T = float>
Position gemmi::Grid< T >::point_to_position ( const Point p) const
inline

Definition at line 419 of file grid.hpp.

◆ grid_modulo()

template<typename T = float>
static double gemmi::Grid< T >::grid_modulo ( double  x,
int  n,
int iptr 
)
inlinestatic

Definition at line 423 of file grid.hpp.

◆ interpolate_value() [1/3]

template<typename T = float>
T gemmi::Grid< T >::interpolate_value ( double  x,
double  y,
double  z 
) const
inline

https://en.wikipedia.org/wiki/Trilinear_interpolation x,y,z are grid coordinates (x=1.5 is between 2nd and 3rd grid point).

Definition at line 431 of file grid.hpp.

◆ interpolate_value() [2/3]

template<typename T = float>
T gemmi::Grid< T >::interpolate_value ( const Fractional fctr) const
inline

Definition at line 452 of file grid.hpp.

◆ interpolate_value() [3/3]

template<typename T = float>
T gemmi::Grid< T >::interpolate_value ( const Position ctr) const
inline

Definition at line 455 of file grid.hpp.

◆ tricubic_interpolation() [1/3]

template<typename T = float>
double gemmi::Grid< T >::tricubic_interpolation ( double  x,
double  y,
double  z 
) const
inline

https://en.wikipedia.org/wiki/Tricubic_interpolation x,y,z are grid coordinates (x=1.5 is between 2nd and 3rd grid point).

Definition at line 461 of file grid.hpp.

◆ tricubic_interpolation() [2/3]

template<typename T = float>
double gemmi::Grid< T >::tricubic_interpolation ( const Fractional fctr) const
inline

Definition at line 473 of file grid.hpp.

◆ tricubic_interpolation() [3/3]

template<typename T = float>
double gemmi::Grid< T >::tricubic_interpolation ( const Position ctr) const
inline

Definition at line 476 of file grid.hpp.

◆ tricubic_interpolation_der() [1/2]

template<typename T = float>
std::array< double, 4 > gemmi::Grid< T >::tricubic_interpolation_der ( double  x,
double  y,
double  z 
) const
inline

returns the same as above + derivatives df/dx, df/dy, df/dz

Definition at line 480 of file grid.hpp.

◆ tricubic_interpolation_der() [2/2]

template<typename T = float>
std::array< double, 4 > gemmi::Grid< T >::tricubic_interpolation_der ( const Fractional fctr) const
inline

Definition at line 505 of file grid.hpp.

◆ interpolate()

template<typename T = float>
T gemmi::Grid< T >::interpolate ( const Fractional f,
int  order 
) const
inline
Parameters
order1=nearest, 2=linear, 3=cubic interpolation

Definition at line 537 of file grid.hpp.

◆ get_subarray()

template<typename T = float>
void gemmi::Grid< T >::get_subarray ( T dest,
std::array< int, 3 >  start,
std::array< int, 3 >  shape 
) const
inline

Definition at line 546 of file grid.hpp.

◆ set_subarray()

template<typename T = float>
void gemmi::Grid< T >::set_subarray ( const T src,
std::array< int, 3 >  start,
std::array< int, 3 >  shape 
)
inline

Definition at line 572 of file grid.hpp.

◆ check_size_for_points_in_box()

template<typename T = float>
template<bool UsePbc>
void gemmi::Grid< T >::check_size_for_points_in_box ( int du,
int dv,
int dw,
bool  fail_on_too_large_radius 
) const
inline

Definition at line 599 of file grid.hpp.

◆ do_use_points_in_box()

template<typename T = float>
template<bool UsePbc, typename Func >
void gemmi::Grid< T >::do_use_points_in_box ( const Fractional fctr,
int  du,
int  dv,
int  dw,
Func &&  func,
double  radius = INFINITY 
)
inline

Definition at line 616 of file grid.hpp.

◆ use_points_in_box()

template<typename T = float>
template<bool UsePbc, typename Func >
void gemmi::Grid< T >::use_points_in_box ( const Fractional fctr,
int  du,
int  dv,
int  dw,
Func &&  func,
bool  fail_on_too_large_radius = true,
double  radius = INFINITY 
)
inline

Definition at line 671 of file grid.hpp.

◆ use_points_around()

template<typename T = float>
template<bool UsePbc, typename Func >
void gemmi::Grid< T >::use_points_around ( const Fractional fctr,
double  radius,
Func &&  func,
bool  fail_on_too_large_radius = true 
)
inline

Definition at line 679 of file grid.hpp.

◆ set_points_around()

template<typename T = float>
void gemmi::Grid< T >::set_points_around ( const Position ctr,
double  radius,
T  value,
bool  use_pbc = true 
)
inline

Definition at line 691 of file grid.hpp.

◆ change_values()

template<typename T = float>
void gemmi::Grid< T >::change_values ( T  old_value,
T  new_value 
)
inline

Definition at line 699 of file grid.hpp.

◆ symmetrize()

template<typename T = float>
template<typename Func >
void gemmi::Grid< T >::symmetrize ( Func  func)
inline

Use.

func to reduce values of all symmetry mates of each
grid point, then assign the result to all the points.
func takes two values and returns a value.

Definition at line 709 of file grid.hpp.

◆ symmetrize_using_ops()

template<typename T = float>
template<typename Func >
void gemmi::Grid< T >::symmetrize_using_ops ( const std::vector< GridOp > &  ops,
Func  func 
)
inline

Definition at line 714 of file grid.hpp.

◆ symmetrize_min()

template<typename T = float>
void gemmi::Grid< T >::symmetrize_min ( )
inline

Definition at line 747 of file grid.hpp.

◆ symmetrize_max()

template<typename T = float>
void gemmi::Grid< T >::symmetrize_max ( )
inline

Definition at line 750 of file grid.hpp.

◆ symmetrize_abs_max()

template<typename T = float>
void gemmi::Grid< T >::symmetrize_abs_max ( )
inline

Definition at line 753 of file grid.hpp.

◆ symmetrize_sum()

template<typename T = float>
void gemmi::Grid< T >::symmetrize_sum ( )
inline

multiplies grid points on special position

Definition at line 757 of file grid.hpp.

◆ symmetrize_nondefault()

template<typename T = float>
void gemmi::Grid< T >::symmetrize_nondefault ( T  default_)
inline

Definition at line 760 of file grid.hpp.

◆ symmetrize_avg()

template<typename T = float>
void gemmi::Grid< T >::symmetrize_avg ( )
inline

Definition at line 763 of file grid.hpp.

◆ normalize()

template<typename T = float>
void gemmi::Grid< T >::normalize ( )
inline

scale the data to get mean == 0 and rmsd == 1 (doesn't work for T=complex)

Definition at line 773 of file grid.hpp.

◆ resample_to()

template<typename T = float>
void gemmi::Grid< T >::resample_to ( Grid< T > &  dest,
int  order 
) const
inline

Definition at line 780 of file grid.hpp.

Member Data Documentation

◆ spacing

template<typename T = float>
double gemmi::Grid< T >::spacing[3] = {0., 0., 0.}

spacing between virtual planes, not between points

Definition at line 312 of file grid.hpp.

◆ orth_n

template<typename T = float>
UpperTriangularMat33 gemmi::Grid< T >::orth_n

unit_cell.orth.mat columns divided by nu, nv, nw

Definition at line 314 of file grid.hpp.


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