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];