76 std::cout <<
"Input: " <<
fnIn << std::endl
77 <<
"Output root: " <<
fnRoot << std::endl
78 <<
"Number eigenvectors: " <<
Neigen << std::endl
79 <<
"Number iterations: " <<
Nits << std::endl <<
"Psi step: " 81 <<
" step: " <<
shift_step << std::endl <<
"Max images: " 91 "Makes a rotational invariant representation of the image collection");
93 " -i <selfile> : Selfile with experimental images");
95 addParamsLine(
" [--eigenvectors <N=200>] : Number of eigenvectors");
96 addParamsLine(
" [--iterations <N=2>] : Number of iterations");
98 " [--max_shift_change <r=0>] : Maximum change allowed in shift");
99 addParamsLine(
" [--psi_step <ang=1>] : Step in psi in degrees");
100 addParamsLine(
" [--shift_step <r=1>] : Step in shift in pixels");
101 addParamsLine(
" [--maxImages <N=-1>] : Maximum number of images");
103 addExampleLine(
"Typical use (4 nodes with 4 processors):",
false);
105 "mpirun -np 4 `which xmipp_mpi_image_rotational_pca` -i images.stk --oroot images_eigen --thr 4");
135 size_t Ydim, Zdim, Ndim;
157 Wnode.push_back(dummyW);
158 Hblock.push_back(dummyHblock);
159 A.push_back(dummyMatrix);
197 size_t Nimgs =
objId.size();
231 int rank = self->rank;
232 std::vector<size_t> &
objId=self->objId;
250 std::cout <<
"Applying T ...\n";
253 while (self->taskDistributor->getTasks(first, last))
255 for (
size_t idx=first; idx<=last; ++idx)
263 size_t Hidx=idx*2*
self->Nangles*
self->Nshifts;
268 for (
int mirror=0; mirror<2; ++mirror)
275 for (
double psi=0;
psi<360;
psi+=
self->psi_step)
278 for (
double y=-self->max_shift_change; y<=self->
max_shift_change;
y+=self->shift_step)
281 for (
double x=-self->max_shift_change; x<=self->
max_shift_change;
x+=self->shift_step, ++block_idx)
297 for (
int j=0;
j<jmax;
j+=unroll, ptrHblock+=unroll, ptrWnode+=unroll)
299 (*ptrWnode) +=pixval*(*ptrHblock);
300 (*(ptrWnode+1)) +=pixval*(*(ptrHblock+1));
301 (*(ptrWnode+2)) +=pixval*(*(ptrHblock+2));
302 (*(ptrWnode+3)) +=pixval*(*(ptrHblock+3));
303 (*(ptrWnode+4)) +=pixval*(*(ptrHblock+4));
304 (*(ptrWnode+5)) +=pixval*(*(ptrHblock+5));
305 (*(ptrWnode+6)) +=pixval*(*(ptrHblock+6));
306 (*(ptrWnode+7)) +=pixval*(*(ptrHblock+7));
309 (*ptrWnode) +=pixval*(*ptrHblock );
346 int rank = self->rank;
347 std::vector<size_t> &
objId=self->objId;
358 const size_t unroll=8;
364 std::cout <<
"Applying Tt ...\n";
367 while (self->taskDistributor->getTasks(first, last))
369 for (
size_t idx=first; idx<=last; ++idx)
377 for (
int mirror=0; mirror<2; ++mirror)
384 for (
double psi=0;
psi<360;
psi+=
self->psi_step)
387 for (
double y=-self->max_shift_change; y<=self->
max_shift_change;
y+=self->shift_step)
390 for (
double x=-self->max_shift_change; x<=self->
max_shift_change;
x+=self->shift_step, ++block_idx)
404 for (
size_t n=0;
n<
nmax;
n+=unroll, ptrIaux+=unroll, ptrMask+=unroll)
407 dotproduct+=(*ptrIaux)*(*ptrWtranspose++);
409 dotproduct+=(*(ptrIaux+1))*(*ptrWtranspose++);
411 dotproduct+=(*(ptrIaux+2))*(*ptrWtranspose++);
413 dotproduct+=(*(ptrIaux+3))*(*ptrWtranspose++);
415 dotproduct+=(*(ptrIaux+4))*(*ptrWtranspose++);
417 dotproduct+=(*(ptrIaux+5))*(*ptrWtranspose++);
419 dotproduct+=(*(ptrIaux+6))*(*ptrWtranspose++);
421 dotproduct+=(*(ptrIaux+7))*(*ptrWtranspose++);
425 dotproduct+=(*ptrIaux)*(*ptrWtranspose++);
435 size_t Hidx=idx*2*
self->Nangles*
self->Nshifts;
473 for (
int it=0; it<2; it++)
475 for (
size_t j2=0; j2<jQ; j2++)
484 const double *ptr2=&
VEC_ELEM(qj2,0);
485 for (
int i=0;
i<iBlockMax;
i++)
487 (*ptr1++)-=s12*(*ptr2++);
488 (*ptr1++)-=s12*(*ptr2++);
489 (*ptr1++)-=s12*(*ptr2++);
490 (*ptr1++)-=s12*(*ptr2++);
493 (*ptr1++)-=s12*(*ptr2++);
519 std::cout <<
"Performing QR decomposition ..." << std::endl;
534 std::cout <<
"Performing SVD decomposition ..." << std::endl;
546 for (
int eig=0; eig<
Neigen; eig++)
572 for (
int it=0; it<
Nits; it++)
606 unlink((
fnRoot+
"_matrixH.raw").c_str());
607 unlink((
fnRoot+
"_matrixF.raw").c_str());
void produceSideInfo()
Produce side info.
ProgImageRotationalPCA()
Empty constructor.
#define FOR_ALL_ELEMENTS_IN_MATRIX2D(m)
std::vector< Matrix2D< double > > Wnode
void init_progress_bar(long total)
#define A2D_ELEM(v, i, j)
virtual void copyHtoF(int block)
std::unique_ptr< ThreadManager > thMgr
double getDoubleParam(const char *param, int arg=0)
__host__ __device__ float2 floor(const float2 v)
virtual void createMutexes(size_t Nimgs)
#define REPORT_ERROR(nerr, ErrormMsg)
std::vector< Matrix2D< double > > A
std::vector< double * > Hbuffer
virtual void selectPartFromMd(MetaData &MDin)
void mapToFile(const FileName &fn, int Ydim, int Xdim, size_t offset=0)
void resizeNoCopy(const MultidimArray< T1 > &v)
std::vector< Matrix2D< double > > Hblock
MultidimArray< unsigned char > mask
static const int HbufferMax
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
void createEmptyFileWithGivenLength(size_t length=0) const
virtual void comunicateQrDim(int &qrDim)
#define MULTIDIM_ARRAY(v)
void compose(const String &str, const size_t no, const String &ext="")
virtual void allReduceApplyT(Matrix2D< double > &Wnode_0)
std::vector< Image< double > > I
std::vector< MetaDataVec > MD
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
std::unique_ptr< Mutex > threadMutex
void resizeNoCopy(int Ydim, int Xdim)
#define MAT_ELEM(m, i, j)
const char * getParam(const char *param, int arg=0)
double dotProduct(const Matrix1D< T > &op1) const
std::vector< double * > HbufferDestination
void progress_bar(long rlen)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
std::unique_ptr< ThreadTaskDistributor > taskDistributor
std::vector< size_t > objId
#define DIRECT_MULTIDIM_ELEM(v, n)
void addExampleLine(const char *example, bool verbatim=true)
std::unique_ptr< Mutex > fileMutex
int verbose
Verbosity level.
void * workClass
The class in which threads will be working.
void svdcmp(const Matrix2D< T > &a, Matrix2D< double > &u, Matrix1D< double > &w, Matrix2D< double > &v)
~ProgImageRotationalPCA()
Destructor.
void threadApplyT(ThreadArgument &thArg)
void threadApplyTt(ThreadArgument &thArg)
void setRow(size_t i, const Matrix1D< T > &v)
virtual void mapMatrix(int qrDim)
void defineParams()
Usage.
double psi(const double x)
int thread_id
The thread id.
void readParams()
Read argument from command line.
void addUsageLine(const char *line, bool verbatim=false)
int getIntParam(const char *param, int arg=0)
Incorrect value received.
void getRow(size_t i, Matrix1D< T > &v) const
void writeToHBuffer(int idx, double *dest)
std::vector< MultidimArray< double > > Iaux
void addParamsLine(const String &line)
virtual void comunicateMatrix(Matrix2D< double > &W)
Matrix2D< double > Wtranspose