50#include "fftmap_sparse.h"
64 spgr_descr_(spgr_descr), grid_sampling_(grid) {}
65 const Spgr_descr& spgr_descr()
const {
return spgr_descr_; }
66 const Grid_sampling& grid_sampling()
const {
return grid_sampling_; }
73 bool matches(
const Key& xmap_cachekey )
const;
81 std::vector<unsigned char>
asu;
83 std::vector<int> du, dv,
dw;
103 enum FFTtype { Default, Normal, Sparse };
124 if (
cacheref.data().asu_grid.in_grid( coord ) ) {
125 const int i =
cacheref.data().map_grid.index( coord );
126 if (
asu[ i ] == 0 )
return i;
208 {
int sym;
map_->find_sym( pos,
index_, sym );
return *
this; }
212 index_++;
if ( last() )
break;
262 inline const int&
sym()
const {
return sym_; }
270 index_++;
if ( last() )
break;
328 inline void find_sym(
const Coord_grid& base,
int& index,
int& sym )
const;
329 void asu_error(
const Coord_grid& pos )
const;
368 {
return list[ix.index()]; }
371 {
return list[ix.index()]; }
375 {
return list[ix.index()]; }
378 {
return list[ix.index()]; }
385 inline const T&
get_data(
const int& index )
const;
387 bool set_data(
const int& index,
const T& val );
403 template<
class H>
void fft_from(
const H& fphidata,
const FFTtype type = Default );
405 template<
class H>
void fft_to ( H& fphidata,
const FFTtype type = Default )
const;
434 void Xmap_base::find_sym(
const Coord_grid& base,
int& index,
int& sym )
const
440 if (
asu[ index ] == 0 ) {
443 sym =
asu[ index ] - 1;
448 for ( sym = 1; sym <
nsym; sym++ ) {
452 if (
asu[ index ] == 0 )
return;
469 find_sym( pos, index, sym );
470 return list[ index ];
480 find_sym( pos, index, sym );
491 {
return list[index]; }
502 if ( index >= 0 && index < list.size() )
503 if ( asu[index] == 0 ) {
521 I::interp( *
this, pos.
coord_map( grid_sam_ ), val );
536 I::interp_grad( *
this, pos.
coord_map( grid_sam_ ), val, g );
554 I::interp_curv( *
this, pos.
coord_map( grid_sam_ ), val, g, c );
571 I::interp( *
this, pos, val );
584 { I::interp_grad( *
this, pos, val, grad ); }
597 { I::interp_curv( *
this, pos, val, grad, curv ); }
604 template<
class T>
template<
class H>
void Xmap<T>::fft_from(
const H& fphidata,
const FFTtype type )
606 if ( type == Sparse || ( type == Default && default_type() == Sparse ) ) {
610 typename H::HKL_reference_index ih;
611 ffttype f, phi0, phi1;
613 for ( ih = fphidata.first_data(); !ih.last(); fphidata.next_data( ih ) ) {
614 f = fphidata[ih].f();
616 phi0 = fphidata[ih].phi();
617 const HKL& hkl = ih.hkl();
619 std::complex<ffttype>( f*cos(phi0), f*sin(phi0) ) );
620 for ( sym = 1; sym < spacegroup_.num_primops(); sym++ ) {
623 std::complex<ffttype>( f*cos(phi1), f*sin(phi1) ) );
634 (*
this)[ix] = fftmap.
real_data( ix.coord() );
639 typename H::HKL_reference_index ih;
640 ffttype f, phi0, phi1;
642 for ( ih = fphidata.first_data(); !ih.last(); fphidata.next_data( ih ) ) {
643 f = fphidata[ih].f();
645 phi0 = fphidata[ih].phi();
646 const HKL& hkl = ih.hkl();
648 std::complex<ffttype>( f*cos(phi0), f*sin(phi0) ) );
649 for ( sym = 1; sym < spacegroup_.num_primops(); sym++ ) {
652 std::complex<ffttype>( f*cos(phi1), f*sin(phi1) ) );
660 (*
this)[ix] = fftmap.
real_data( ix.coord() );
673 template<
class T>
template<
class H>
void Xmap<T>::fft_to ( H& fphidata,
const FFTtype type )
const
675 if ( type == Sparse || ( type == Default && default_type() == Sparse ) ) {
685 for ( sym = 1; sym < cacheref.data().nsym; sym++ )
687 ix.coord().transform( isymop[sym] ).unit( grid_sam_ ) ) = f;
691 typename H::HKL_reference_index ih;
692 for ( ih = fphidata.first(); !ih.last(); ih.next() )
697 for ( ih = fphidata.first(); !ih.last(); ih.next() ) {
698 std::complex<ffttype> c = fftmap.
get_hkl( ih.hkl() );
699 fphidata[ih].f() = std::abs(c);
700 fphidata[ih].phi() = std::arg(c);
712 for ( sym = 1; sym < cacheref.data().nsym; sym++ )
714 ix.coord().transform( isymop[sym] ).unit( grid_sam_ ) ) = f;
720 typename H::HKL_reference_index ih;
721 for ( ih = fphidata.first(); !ih.last(); ih.next() ) {
722 std::complex<ffttype> c = fftmap.
get_hkl( ih.hkl() );
723 fphidata[ih].f() = std::abs(c);
724 fphidata[ih].phi() = std::arg(c);
736 list[im.index()] = value;
744 if ( spacegroup().hash() != other.spacegroup().
hash() ||
745 grid_sampling() != other.grid_sampling() )
748 list[im.index()] += other[im];
755 if ( spacegroup().hash() != other.spacegroup().
hash() ||
756 grid_sampling() != other.grid_sampling() )
759 list[im.index()] -= other[im];
Simple 2-d array class.
Definition clipper_types.h:365
Cell object.
Definition cell.h:122
fractional (cell) coordinates
Definition coords.h:343
Coord_map coord_map(const Grid &g) const
fractional-grid coordinate conversion
Definition coords.h:791
Grid coordinate.
Definition coords.h:237
const int & v() const
get v
Definition coords.h:249
Coord_grid unit(const Grid_sampling &g) const
reduce to unit box: (0..nu-1, 0..nv-1, 0..nw-1)
Definition coords.h:744
const int & w() const
get w
Definition coords.h:250
Coord_grid transform(const Isymop &op) const
return transformed coordinate
Definition coords.h:260
void deindex(const Grid &g, const int &index)
grid deindexing operator
Definition coords.h:740
const int & u() const
get u
Definition coords.h:248
map coordinate: this is like Coord_grid, but non-integer
Definition coords.h:388
orthogonal (Angstrom) coordinates
Definition coords.h:303
fractional (cell) curvatures, with respect to fractional u,v,w
Definition derivs.h:132
map coordinate curvatures, with respect to grid u,v,w
Definition derivs.h:146
Curv_frac< T > curv_frac(const Grid &g) const
grid-fractional derivative conversion
Definition derivs.h:226
FFTmap_p1: low level P1 map used for calculating FFTs.
Definition fftmap.h:81
void fft_h_to_x(const ftype &scale)
Transform to real space.
Definition fftmap.cpp:149
const ffttype & real_data(const Coord_grid &c) const
get real space data
Definition fftmap.h:119
void set_hkl(const HKL &hkl, const std::complex< ffttype > &f)
set reciprocal space data: slow form with hemisphere check
Definition fftmap.cpp:229
std::complex< ffttype > get_hkl(const HKL &hkl) const
get reciprocal space data: slow form with hemisphere check
Definition fftmap.cpp:213
void fft_x_to_h(const ftype &scale)
Transform to reciprocal space.
Definition fftmap.cpp:181
FFTmap_sparse_p1_hx: low level sparse P1 map used for calculating FFTs.
Definition fftmap_sparse.h:92
void set_hkl(const HKL &hkl, const std::complex< ffttype > &f)
set reciprocal space data by hkl
Definition fftmap_sparse.cpp:143
void fft_h_to_x(const ftype &scale)
Transform to real space.
Definition fftmap_sparse.cpp:157
void require_real_data(const Coord_grid &uvw)
express need for real space data
Definition fftmap_sparse.h:108
const ffttype & real_data(const Coord_grid &uvw) const
get real space data ( uvw must be in grid_real() )
Definition fftmap_sparse.h:111
FFTmap_sparse_p1_xh: low level sparse P1 map used for calculating FFTs.
Definition fftmap_sparse.h:125
void require_hkl(const HKL &hkl)
express need for reciprocal space data by hkl
Definition fftmap_sparse.cpp:255
void fft_x_to_h(const ftype &scale)
Transform to real space.
Definition fftmap_sparse.cpp:294
ffttype & real_data(const Coord_grid &uvw)
set real space data ( uvw must be in grid_real() )
Definition fftmap_sparse.h:136
const std::complex< ffttype > get_hkl(const HKL &hkl) const
get reciprocal space data by hkl
Definition fftmap_sparse.cpp:267
fractional (cell) gradient, with respect to fractional u,v,w
Definition derivs.h:82
map coordinate gradient, with respect to grid u,v,w
Definition derivs.h:102
Grad_frac< T > grad_frac(const Grid &g) const
grid-fractional derivative conversion
Definition derivs.h:189
Grid range class: defines array limits for a grid.
Definition coords.h:585
Coord_grid deindex(const int &index) const
grid deindexing operator
Definition coords.h:607
int index(const Coord_grid &c) const
grid indexing operator
Definition coords.h:605
bool in_grid(Coord_grid g) const
determine if a point is in the grid
Definition coords.h:602
Grid sampling of a unit cell.
Definition coords.h:516
int size() const
return size of grid array
Definition coords.h:489
reflection 'Miller' index
Definition coords.h:146
HKL transform(const Symop &op) const
return transformed hkl
Definition coords.h:696
ftype sym_phase_shift(const Symop &op) const
return symmetry phase shift for this HKL under op
Definition coords.h:707
Integerised symmetry matrix.
Definition symop.h:109
3x3-matrix class
Definition clipper_types.h:183
Fatal message (level = 9)
Definition clipper_message.h:129
static void message(const T &message)
pass a message
Definition clipper_message.h:93
Mutex class: used for locking and unlocking shared resources.
Definition clipper_thread.h:64
ObjectCache reference class.
Definition clipper_memory.h:155
Rotation-translation operator.
Definition clipper_types.h:323
const Mat33< T > & rot() const
get rotation
Definition clipper_types.h:337
Spacegroup object.
Definition spacegroup.h:173
spacegroup description
Definition spacegroup.h:74
const unsigned int & hash() const
return the hash code for the spacegroup
Definition spacegroup.h:133
String extension with simple parsing methods.
Definition clipper_types.h:65
Map reference base class.
Definition xmap.h:163
int index_
integer index_ into map data array
Definition xmap.h:175
const int & index() const
Get the index into the map data array.
Definition xmap.h:168
bool last() const
Check for end of map.
Definition xmap.h:170
const Xmap_base * map_
pointer to map for which this Map_reference_index is defined
Definition xmap.h:173
const Xmap_base & base_xmap() const
return the parent Xmap
Definition xmap.h:166
Map reference with coordinate-like behaviour.
Definition xmap.h:243
Map_reference_coord & set_coord(const Coord_grid &pos)
Set current value of coordinate - optimised for nearby coords.
Definition xmap.cpp:136
void edge()
Reset index for a different symop when we hit the map border.
Definition xmap.cpp:152
Map_reference_coord()
Null constructor.
Definition xmap.h:246
const Coord_orth coord_orth() const
Get current value of orthogonal coordinate.
Definition xmap.h:259
const Coord_grid & coord() const
Get current value of coordinate.
Definition xmap.h:257
Map_reference_coord & next_v()
increment v
Definition xmap.h:277
Map_reference_coord(const Xmap_base &map, const Coord_grid &pos)
Constructor: takes parent map and coord.
Definition xmap.h:251
Map_reference_coord(const Xmap_base &map)
Constructor: takes parent map.
Definition xmap.h:248
int sym_
Current symop.
Definition xmap.h:292
Map_reference_coord & prev_w()
decrement w
Definition xmap.h:281
Map_reference_coord & prev_u()
increment u
Definition xmap.h:279
Map_reference_coord & next_w()
increment w
Definition xmap.h:278
Map_reference_coord & next()
Simple increment.
Definition xmap.h:267
Map_reference_coord & operator=(const Coord_grid &pos)
Assignment operator from a coord.
Definition xmap.h:283
const int & sym() const
Get current symmetry operator.
Definition xmap.h:262
Coord_grid pos_
Current coord.
Definition xmap.h:294
Map_reference_coord & next_u()
increment u
Definition xmap.h:276
Map_reference_coord & prev_v()
decrement v
Definition xmap.h:280
Map reference with index-like behaviour.
Definition xmap.h:191
Map_reference_index()
Null constructor.
Definition xmap.h:194
Map_reference_index(const Xmap_base &map)
Constructor: takes parent map.
Definition xmap.h:196
int index_offset(const int &du, const int &dv, const int &dw) const
Index of neighbouring point.
Definition xmap.h:219
Coord_grid coord() const
Get current grid coordinate.
Definition xmap.h:201
Map_reference_index & set_coord(const Coord_grid &pos)
Set current value of coordinate - optimised for nearby coords.
Definition xmap.h:207
const Coord_orth coord_orth() const
Get current value of orthogonal coordinate.
Definition xmap.h:204
Map_reference_index(const Xmap_base &map, const Coord_grid &pos)
Constructor: takes parent map and coord.
Definition xmap.h:199
Map_reference_index & next()
Simple increment.
Definition xmap.h:210
Xmap_base: base for crystallographic map class.
Definition xmap.h:101
ObjectCache< Xmap_cacheobj >::Reference cacheref
object cache reference
Definition xmap.h:307
const RTop & operator_orth_grid() const
return the orthogonal-to-grid coordinate operator (translation is zero)
Definition xmap.h:135
Map_reference_coord first_coord() const
return a Map_reference_coord for this map
Definition xmap.h:303
Spacegroup spacegroup_
spacegroup
Definition xmap.h:318
const Isymop * isymop
fast access ptr
Definition xmap.h:309
bool is_null() const
test if object has been initialised
Definition xmap.cpp:200
bool in_map(const Coord_grid &) const
(This method is for compatibility with NXmap - it always returns true)
Definition xmap.h:150
const Grid_sampling & grid_sampling() const
get the cell grid
Definition xmap.h:113
const Grid_range & grid_asu() const
get the ASU grid
Definition xmap.h:115
static FFTtype & default_type()
set/get default backend type
Definition xmap.h:305
Grid_range map_grid
fast access copy
Definition xmap.h:314
const int * dw
fast access ptr
Definition xmap.h:312
RTop rt_grid_orth
grid->orth operator
Definition xmap.h:322
RTop rt_orth_grid
orth->grid operator
Definition xmap.h:321
const Cell & cell() const
get the cell
Definition xmap.h:109
int nsym
fast access copy
Definition xmap.h:315
const int * du
fast access ptr
Definition xmap.h:310
const unsigned char * asu
fast access ptr
Definition xmap.h:308
Xmap_base()
Null constructor, for later initialisation.
Definition xmap.cpp:131
void init(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
initialiser
Definition xmap.cpp:171
Grid_range asu_grid
fast access copy
Definition xmap.h:313
Coord_grid coord_of(const int &index) const
map coordinate from index
Definition xmap.h:118
int multiplicity(const Coord_grid &pos) const
get multiplicity of a map grid point
Definition xmap.cpp:211
bool in_map(const Coord_map &cm) const
(This method is for compatibility with NXmap - it always returns true)
Definition xmap.h:152
Cell cell_
unit cell
Definition xmap.h:317
const RTop & operator_grid_orth() const
return the grid-to-orthogonal coordinate operator (translation is zero)
Definition xmap.h:137
Coord_map coord_map(const Coord_orth &co) const
convert orthogonal coordinate to map
Definition xmap.h:146
static FFTtype default_type_
default backend type
Definition xmap.h:331
const int * dv
fast access ptr
Definition xmap.h:311
const Spacegroup & spacegroup() const
get the spacegroup
Definition xmap.h:111
Coord_grid to_map_unit(const Coord_grid &pos) const
function to pick right cell repeat for any grid coord
Definition xmap.h:131
Coord_orth coord_orth(const Coord_map &cm) const
convert map coordinate to orthogonal
Definition xmap.h:141
Map_reference_index first() const
return a Map_reference_index for this map
Definition xmap.h:301
Grid_sampling grid_sam_
grid for the whole cell
Definition xmap.h:319
int index_of(const Coord_grid &coord) const
map index from coordinate
Definition xmap.h:123
Grid_sampling xtl_grid
grid for the cell
Definition xmap.h:77
std::vector< int > dw
symmetry grid shifts to index
Definition xmap.h:83
Mat33 mat_grid_orth
for backward compatibility
Definition xmap.h:85
bool matches(const Key &xmap_cachekey) const
compare entry
Definition xmap.cpp:112
Grid_range asu_grid
grid for the ASU
Definition xmap.h:78
Array2d< unsigned char > symperm
Perumtation matrix of symops.
Definition xmap.h:84
std::vector< Isymop > isymop
Integerised symops.
Definition xmap.h:82
Grid_range map_grid
grid for the ASU, plus border
Definition xmap.h:79
std::vector< unsigned char > asu
ASU flag array.
Definition xmap.h:81
String format() const
string description
Definition xmap.cpp:121
Key key
key
Definition xmap.h:76
static Mutex mutex
thread safety
Definition xmap.h:86
Xmap<T>: actual crystallographic map class.
Definition xmap.h:357
const T & operator[](const Xmap_base::Map_reference_index &ix) const
get data by Map_reference_index
Definition xmap.h:367
void interp_grad(const Coord_frac &pos, T &val, Grad_frac< T > &grad) const
get map value and grad for fractional coord using supplied interpolator
Definition xmap.h:533
void set_data(const Coord_grid &pos, const T &val)
set a density value for an arbitrary position
Definition xmap.h:477
Xmap(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
constructor: from spacegroup, cell, and grid
Definition xmap.h:362
const T & get_data(const Coord_grid &pos) const
get a density value for an arbitrary position
Definition xmap.h:466
const Xmap< T > & operator+=(const Xmap< T > &other)
add another map to this one
Definition xmap.h:742
void fft_to(H &fphidata, const FFTtype type=Default) const
FFT from map to reflection list.
Definition xmap.h:673
void fft_from(const H &fphidata, const FFTtype type=Default)
FFT from reflection list to map.
Definition xmap.h:604
void interp_curv(const Coord_frac &pos, T &val, Grad_frac< T > &grad, Curv_frac< T > &curv) const
get map value and curv for fractional coord using supplied interpolator
Definition xmap.h:550
Xmap()
Null constructor, for later initialisation.
Definition xmap.h:360
T interp(const Coord_frac &pos) const
get map value for fractional coord using supplied interpolator
Definition xmap.h:518
const Xmap< T > & operator-=(const Xmap< T > &other)
subtract another map from this one
Definition xmap.h:753
void init(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
initialiser: from spacegroup, cell, and grid
Definition xmap.h:364
const T & operator=(const T &value)
assignment operator: assigns a single value to the whole map
Definition xmap.h:732