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 };
119 {
return cacheref.data().map_grid.deindex( index ); }
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 );
555 grad = g.grad_frac( grid_sam_ );
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];
std::complex< ffttype > get_hkl(const HKL &hkl) const
get reciprocal space data: slow form with hemisphere check
Definition: fftmap.cpp:213
void set_hkl(const HKL &hkl, const std::complex< ffttype > &f)
set reciprocal space data: slow form with hemisphere check
Definition: fftmap.cpp:229
bool matches(const Key &xmap_cachekey) const
compare entry
Definition: xmap.cpp:112
const int & u() const
get u
Definition: coords.h:248
Map_reference_coord & next_v()
increment v
Definition: xmap.h:277
void set_data(const Coord_grid &pos, const T &val)
set a density value for an arbitrary position
Definition: xmap.h:477
Coord_orth coord_orth(const Coord_map &cm) const
convert map coordinate to orthogonal
Definition: xmap.h:141
void fft_from(const H &fphidata, const FFTtype type=Default)
FFT from reflection list to map.
Definition: xmap.h:604
Map_reference_coord & set_coord(const Coord_grid &pos)
Set current value of coordinate - optimised for nearby coords.
Definition: xmap.cpp:136
void fft_h_to_x(const ftype &scale)
Transform to real space.
Definition: fftmap.cpp:149
Map reference with coordinate-like behaviour.
Definition: xmap.h:242
Fatal message (level = 9)
Definition: clipper_message.h:129
const int * dw
fast access ptr
Definition: xmap.h:312
void fft_x_to_h(const ftype &scale)
Transform to real space.
Definition: fftmap_sparse.cpp:294
Spacegroup spacegroup_
spacegroup
Definition: xmap.h:318
const Cell & cell() const
get the cell
Definition: xmap.h:109
const Xmap< T > & operator+=(const Xmap< T > &other)
add another map to this one
Definition: xmap.h:742
const Coord_grid & coord() const
Get current value of coordinate.
Definition: xmap.h:257
static FFTtype & default_type()
set/get default backend type
Definition: xmap.h:305
map coordinate: this is like Coord_grid, but non-integer
Definition: coords.h:387
orthogonal (Angstrom) coordinates
Definition: coords.h:302
const T & get_data(const Coord_grid &pos) const
get a density value for an arbitrary position
Definition: xmap.h:466
Map_reference_index(const Xmap_base &map, const Coord_grid &pos)
Constructor: takes parent map and coord.
Definition: xmap.h:199
Grid coordinate.
Definition: coords.h:236
const ffttype & real_data(const Coord_grid &c) const
get real space data
Definition: fftmap.h:119
const Coord_orth coord_orth() const
Get current value of orthogonal coordinate.
Definition: xmap.h:204
int index(const Coord_grid &c) const
grid indexing operator
Definition: coords.h:605
std::vector< int > dw
symmetry grid shifts to index
Definition: xmap.h:83
const unsigned char * asu
fast access ptr
Definition: xmap.h:308
void fft_x_to_h(const ftype &scale)
Transform to reciprocal space.
Definition: fftmap.cpp:181
Xmap_cacheobj(const Key &xmap_cachekey)
construct entry
Definition: xmap.cpp:55
bool in_map(const Coord_map &cm) const
(This method is for compatibility with NXmap - it always returns true)
Definition: xmap.h:152
const T & operator=(const T &value)
assignment operator: assigns a single value to the whole map
Definition: xmap.h:732
void fft_to(H &fphidata, const FFTtype type=Default) const
FFT from map to reflection list.
Definition: xmap.h:673
Coord_grid to_map_unit(const Coord_grid &pos) const
function to pick right cell repeat for any grid coord
Definition: xmap.h:131
Map_reference_coord & prev_w()
decrement w
Definition: xmap.h:281
fractional (cell) curvatures, with respect to fractional u,v,w
Definition: derivs.h:58
FFTmap_p1: low level P1 map used for calculating FFTs.
Definition: fftmap.h:80
const std::complex< ffttype > get_hkl(const HKL &hkl) const
get reciprocal space data by hkl
Definition: fftmap_sparse.cpp:267
String format() const
string description
Definition: xmap.cpp:121
const int * du
fast access ptr
Definition: xmap.h:310
Map_reference_coord(const Xmap_base &map)
Constructor: takes parent map.
Definition: xmap.h:248
Coord_map coord_map(const Grid &g) const
fractional-grid coordinate conversion
Definition: coords.h:791
const Grid_sampling & grid_sampling() const
get the cell grid
Definition: xmap.h:113
void require_hkl(const HKL &hkl)
express need for reciprocal space data by hkl
Definition: fftmap_sparse.cpp:255
fractional (cell) coordinates
Definition: coords.h:342
void init(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
initialiser: from spacegroup, cell, and grid
Definition: xmap.h:364
RTop rt_orth_grid
orth->grid operator
Definition: xmap.h:321
Grid_sampling xtl_grid
grid for the cell
Definition: xmap.h:77
static FFTtype default_type_
default backend type
Definition: xmap.h:331
std::vector< Isymop > isymop
Integerised symops.
Definition: xmap.h:82
const Isymop * isymop
fast access ptr
Definition: xmap.h:309
int multiplicity(const Coord_grid &pos) const
get multiplicity of a map grid point
Definition: xmap.cpp:211
Coord_map coord_map(const Coord_orth &co) const
convert orthogonal coordinate to map
Definition: xmap.h:146
Map_reference_coord()
Null constructor.
Definition: xmap.h:246
spacegroup description
Definition: spacegroup.h:73
Map_reference_index & set_coord(const Coord_grid &pos)
Set current value of coordinate - optimised for nearby coords.
Definition: xmap.h:207
FFTmap_sparse_p1_xh: low level sparse P1 map used for calculating FFTs.
Definition: fftmap_sparse.h:124
int size() const
return size of grid array
Definition: coords.h:489
const int & index() const
Get the index into the map data array.
Definition: xmap.h:168
Coord_grid deindex(const int &index) const
grid deindexing operator
Definition: coords.h:607
Xmap_base()
Null constructor, for later initialisation.
Definition: xmap.cpp:131
Grad_frac< T > grad_frac(const Grid &g) const
grid-fractional derivative conversion
Definition: derivs.h:189
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
Grid_sampling grid_sam_
grid for the whole cell
Definition: xmap.h:319
Map_reference_coord & prev_v()
decrement v
Definition: xmap.h:280
ObjectCache reference class.
Definition: clipper_memory.h:154
std::vector< unsigned char > asu
ASU flag array.
Definition: xmap.h:81
Map_reference_index(const Xmap_base &map)
Constructor: takes parent map.
Definition: xmap.h:196
Map_reference_coord & prev_u()
increment u
Definition: xmap.h:279
Cell object.
Definition: cell.h:121
Spacegroup object.
Definition: spacegroup.h:172
Coord_grid transform(const Isymop &op) const
return transformed coordinate
Definition: coords.h:260
Xmap_base: base for crystallographic map class.
Definition: xmap.h:100
map coordinate curvatures, with respect to grid u,v,w
Definition: derivs.h:59
const Xmap< T > & operator-=(const Xmap< T > &other)
subtract another map from this one
Definition: xmap.h:753
bool in_grid(Coord_grid g) const
determine if a point is in the grid
Definition: coords.h:602
const Spacegroup & spacegroup() const
get the spacegroup
Definition: xmap.h:111
bool last() const
Check for end of map.
Definition: xmap.h:170
Grid range class: defines array limits for a grid.
Definition: coords.h:584
Key key
key
Definition: xmap.h:76
ObjectCache< Xmap_cacheobj >::Reference cacheref
object cache reference
Definition: xmap.h:307
Grid_range map_grid
fast access copy
Definition: xmap.h:314
String extension with simple parsing methods.
Definition: clipper_types.h:64
Map_reference_coord & operator=(const Coord_grid &pos)
Assignment operator from a coord.
Definition: xmap.h:283
Xmap(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
constructor: from spacegroup, cell, and grid
Definition: xmap.h:362
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
Map reference with index-like behaviour.
Definition: xmap.h:190
Map_reference_coord first_coord() const
return a Map_reference_coord for this map
Definition: xmap.h:303
const int & w() const
get w
Definition: coords.h:250
Grid_range asu_grid
fast access copy
Definition: xmap.h:313
Array2d< unsigned char > symperm
Perumtation matrix of symops.
Definition: xmap.h:84
void fft_h_to_x(const ftype &scale)
Transform to real space.
Definition: fftmap_sparse.cpp:157
Mat33 mat_grid_orth
for backward compatibility
Definition: xmap.h:85
Coord_grid coord() const
Get current grid coordinate.
Definition: xmap.h:201
Mutex class: used for locking and unlocking shared resources.
Definition: clipper_thread.h:64
int nsym
fast access copy
Definition: xmap.h:315
HKL transform(const Symop &op) const
return transformed hkl
Definition: coords.h:696
void edge()
Reset index for a different symop when we hit the map border.
Definition: xmap.cpp:152
static void message(const T &message)
pass a message
Definition: clipper_message.h:93
int index_offset(const int &du, const int &dv, const int &dw) const
Index of neighbouring point.
Definition: xmap.h:219
bool is_null() const
test if object has been initialised
Definition: xmap.cpp:200
Grid sampling of a unit cell.
Definition: coords.h:515
Map reference base class.
Definition: xmap.h:162
const unsigned int & hash() const
return the hash code for the spacegroup
Definition: spacegroup.h:133
const ffttype & real_data(const Coord_grid &uvw) const
get real space data ( uvw must be in grid_real() )
Definition: fftmap_sparse.h:111
void set_hkl(const HKL &hkl, const std::complex< ffttype > &f)
set reciprocal space data by hkl
Definition: fftmap_sparse.cpp:143
Map_reference_coord & next()
Simple increment.
Definition: xmap.h:267
const Mat33< T > & rot() const
get rotation
Definition: clipper_types.h:337
map coordinate gradient, with respect to grid u,v,w
Definition: derivs.h:56
Map_reference_coord & next_w()
increment w
Definition: xmap.h:278
const Coord_orth coord_orth() const
Get current value of orthogonal coordinate.
Definition: xmap.h:259
const RTop & operator_grid_orth() const
return the grid-to-orthogonal coordinate operator (translation is zero)
Definition: xmap.h:137
const int & v() const
get v
Definition: coords.h:249
Xmap()
Null constructor, for later initialisation.
Definition: xmap.h:360
Map_reference_coord & next_u()
increment u
Definition: xmap.h:276
Coord_grid coord_of(const int &index) const
map coordinate from index
Definition: xmap.h:118
int sym_
Current symop.
Definition: xmap.h:292
FFTmap_sparse_p1_hx: low level sparse P1 map used for calculating FFTs.
Definition: fftmap_sparse.h:91
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
Map_reference_index & next()
Simple increment.
Definition: xmap.h:210
int index_of(const Coord_grid &coord) const
map index from coordinate
Definition: xmap.h:123
Curv_frac< T > curv_frac(const Grid &g) const
grid-fractional derivative conversion
Definition: derivs.h:226
bool in_map(const Coord_grid &) const
(This method is for compatibility with NXmap - it always returns true)
Definition: xmap.h:150
Map_reference_index first() const
return a Map_reference_index for this map
Definition: xmap.h:301
const RTop & operator_orth_grid() const
return the orthogonal-to-grid coordinate operator (translation is zero)
Definition: xmap.h:135
RTop rt_grid_orth
grid->orth operator
Definition: xmap.h:322
ffttype & real_data(const Coord_grid &uvw)
set real space data ( uvw must be in grid_real() )
Definition: fftmap_sparse.h:136
fractional (cell) gradient, with respect to fractional u,v,w
Definition: derivs.h:55
Coord_grid pos_
Current coord.
Definition: xmap.h:294
ftype sym_phase_shift(const Symop &op) const
return symmetry phase shift for this HKL under op
Definition: coords.h:707
static Mutex mutex
thread safety
Definition: xmap.h:86
const Xmap_base & base_xmap() const
return the parent Xmap
Definition: xmap.h:166
Grid_range asu_grid
grid for the ASU
Definition: xmap.h:78
void init(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
initialiser
Definition: xmap.cpp:171
Map_reference_index()
Null constructor.
Definition: xmap.h:194
const T & operator[](const Xmap_base::Map_reference_index &ix) const
get data by Map_reference_index
Definition: xmap.h:367
reflection 'Miller' index
Definition: coords.h:145
int index_
integer index_ into map data array
Definition: xmap.h:175
Integerised symmetry matrix.
Definition: symop.h:108
const Grid_range & grid_asu() const
get the ASU grid
Definition: xmap.h:115
Map_reference_coord(const Xmap_base &map, const Coord_grid &pos)
Constructor: takes parent map and coord.
Definition: xmap.h:251
Coord_map coord_map() const
convert to Coord_map
Definition: coords.h:747
Cell cell_
unit cell
Definition: xmap.h:317
Xmap: actual crystallographic map class.
Definition: xmap.h:356
3x3-matrix class
Definition: clipper_types.h:182
T interp(const Coord_frac &pos) const
get map value for fractional coord using supplied interpolator
Definition: xmap.h:518
void require_real_data(const Coord_grid &uvw)
express need for real space data
Definition: fftmap_sparse.h:108
Grid_range map_grid
grid for the ASU, plus border
Definition: xmap.h:79
const Xmap_base * map_
pointer to map for which this Map_reference_index is defined
Definition: xmap.h:173
const int * dv
fast access ptr
Definition: xmap.h:311
const int & sym() const
Get current symmetry operator.
Definition: xmap.h:262