ProSHADE  0.7.6.6 (JUL 2022)
Protein Shape Detection
ProSHADE_internal_wigner Namespace Reference

This namespace contains all the functionality required to perform object rotation in SO(3) space. More...

Functions

void allocateWignerWorkspace (proshade_double *&matIn, proshade_double *&matOut, proshade_double *&sqrts, proshade_double *&workspace, proshade_double *&alphaExponentReal, proshade_double *&alphaExponentImag, proshade_double *&gammaExponentReal, proshade_double *&gammaExponentImag, proshade_double *&trigs, proshade_unsign compBand)
 This function allocates the memory for the Wigner matrices computation. More...
 
void releaseWignerWorkspace (proshade_double *&matIn, proshade_double *&matOut, proshade_double *&sqrts, proshade_double *&workspace, proshade_double *&alphaExponentReal, proshade_double *&alphaExponentImag, proshade_double *&gammaExponentReal, proshade_double *&gammaExponentImag, proshade_double *&trigs)
 This function releases the memory for the Wigner matrices computation. More...
 
void prepareTrigsSqrtsAndExponents (proshade_double *sqrts, proshade_double *alphaExponentReal, proshade_double *alphaExponentImag, proshade_double *gammaExponentReal, proshade_double *gammaExponentImag, proshade_double *trigs, proshade_unsign compBand, proshade_double angAlpha, proshade_double angBeta, proshade_double angGamma)
 This function sets all the values repeatedly required for the computation. More...
 
void computeWignerMatrices (ProSHADE_settings *settings, ProSHADE_internal_data::ProSHADE_data *obj, proshade_double *alphaExponentReal, proshade_double *alphaExponentImag, proshade_double *gammaExponentReal, proshade_double *gammaExponentImag, proshade_double *matIn, proshade_double *matOut, proshade_double *trigs, proshade_double *sqrts, proshade_double *workspace)
 This function does the actual computation of the Wigner D matrices. More...
 
void computeWignerMatricesForRotation (ProSHADE_settings *settings, ProSHADE_internal_data::ProSHADE_data *obj, proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma)
 This function computes the Wigner D matrices for a particular set of Euler angles. More...
 

Detailed Description

This namespace contains all the functionality required to perform object rotation in SO(3) space.

The ProSHADE namespace wraps around all the functions required to compute Wigner d and D matrices for any perticular rotation (as given by the ZYZ Euler angles) and applying these to the SO(3) coefficients of any object.

Function Documentation

◆ allocateWignerWorkspace()

void ProSHADE_internal_wigner::allocateWignerWorkspace ( proshade_double *&  matIn,
proshade_double *&  matOut,
proshade_double *&  sqrts,
proshade_double *&  workspace,
proshade_double *&  alphaExponentReal,
proshade_double *&  alphaExponentImag,
proshade_double *&  gammaExponentReal,
proshade_double *&  gammaExponentImag,
proshade_double *&  trigs,
proshade_unsign  compBand 
)

This function allocates the memory for the Wigner matrices computation.

This function allocates all the internal computation space, which will be required only for the duration of the computation and not after.

Parameters
[in]matInA pointer to the array holding the inputs for Wigner d matrix computation by SOFT.
[in]matOutA pointer to the array holding the outputs for Wigner d matrix computation by SOFT.
[in]sqrtsArray of square roots of the bands.
[in]workspaceArray required by SOFT for internal computation space.
[in]alphaExponentRealAn array of exponents of the alpha angle for the real part of the Wigner matrices.
[in]alphaExponentImagAn array of exponents of the alpha angle for the imaginary part of the Wigner matrices.
[in]gammaExponentRealAn array of exponents of the gamma angle for the real part of the Wigner matrices.
[in]gammaExponentImagAn array of exponents of the gamma angle for the imaginary part of the Wigner matrices.
[in]trigsArray of 2 doubles holding the trigonometric results for the beta angle.
[in]compBandThe bendwidth of the computation.

Definition at line 75 of file ProSHADE_wignerMatrices.cpp.

76 {
77  //================================================ Allocate the memory
78  matIn = new proshade_double[static_cast<proshade_unsign> ( 4 * pow( compBand, 2.0 ) ) - 4 * compBand + 1];
79 
80  matOut = new proshade_double[static_cast<proshade_unsign> ( 4 * pow( compBand, 2.0 ) ) - 4 * compBand + 1];
81  sqrts = new proshade_double[static_cast<proshade_unsign> ( 2 * compBand )];
82  workspace = new proshade_double[static_cast<proshade_unsign> ( 4 * pow( compBand, 2.0 ) )];
83  alphaExponentReal = new proshade_double[static_cast<proshade_unsign> ( 2 * compBand - 1 )];
84  alphaExponentImag = new proshade_double[static_cast<proshade_unsign> ( 2 * compBand - 1 )];
85  gammaExponentReal = new proshade_double[static_cast<proshade_unsign> ( 2 * compBand - 1 )];
86  gammaExponentImag = new proshade_double[static_cast<proshade_unsign> ( 2 * compBand - 1 )];
87  trigs = new proshade_double[2];
88 
89  //================================================ Check memory allocation
90  ProSHADE_internal_misc::checkMemoryAllocation ( matIn, __FILE__, __LINE__, __func__ );
91  ProSHADE_internal_misc::checkMemoryAllocation ( matOut, __FILE__, __LINE__, __func__ );
92  ProSHADE_internal_misc::checkMemoryAllocation ( sqrts, __FILE__, __LINE__, __func__ );
93  ProSHADE_internal_misc::checkMemoryAllocation ( workspace, __FILE__, __LINE__, __func__ );
94  ProSHADE_internal_misc::checkMemoryAllocation ( alphaExponentReal, __FILE__, __LINE__, __func__ );
95  ProSHADE_internal_misc::checkMemoryAllocation ( alphaExponentImag, __FILE__, __LINE__, __func__ );
96  ProSHADE_internal_misc::checkMemoryAllocation ( gammaExponentReal, __FILE__, __LINE__, __func__ );
97  ProSHADE_internal_misc::checkMemoryAllocation ( gammaExponentImag, __FILE__, __LINE__, __func__ );
98  ProSHADE_internal_misc::checkMemoryAllocation ( trigs, __FILE__, __LINE__, __func__ );
99 
100  //================================================ Done
101  return ;
102 
103 }

◆ computeWignerMatrices()

void ProSHADE_internal_wigner::computeWignerMatrices ( ProSHADE_settings settings,
ProSHADE_internal_data::ProSHADE_data obj,
proshade_double *  alphaExponentReal,
proshade_double *  alphaExponentImag,
proshade_double *  gammaExponentReal,
proshade_double *  gammaExponentImag,
proshade_double *  matIn,
proshade_double *  matOut,
proshade_double *  trigs,
proshade_double *  sqrts,
proshade_double *  workspace 
)

This function does the actual computation of the Wigner D matrices.

This function is the workhorse of the Wigner D matrices computation. It does iterate throught all the appropriate bands and order combinations and it computes the Wigner D matrix (l,m,m') values using the Wigner d matrices (which only take into account the beta Euler ZYZ angle) and the exponents obtained using the Euler ZYZ alpha and gamma angles. It also deals with the signs, but it does not deal with the memory allocation, release and general value set-up.

Parameters
[in]settingsA pointer to settings class containing all the information required for the task.
[in]objA ProSHADE_data class object for which the Wigner matrices should be computed.
[in]alphaExponentRealAn array of exponents of the alpha angle for the real part of the Wigner matrices.
[in]alphaExponentImagAn array of exponents of the alpha angle for the imaginary part of the Wigner matrices.
[in]gammaExponentRealAn array of exponents of the gamma angle for the real part of the Wigner matrices.
[in]gammaExponentImagAn array of exponents of the gamma angle for the imaginary part of the Wigner matrices.
[in]matInA pointer to the array holding the inputs for Wigner d matrix computation by SOFT.
[in]matOutA pointer to the array holding the outputs for Wigner d matrix computation by SOFT.
[in]trigsproshade_complex pointer which holds the beta angle trigonometric function results.
[in]sqrtsArray of square roots of the bands.
[in]workspaceArray required by SOFT for internal computation space.

Definition at line 187 of file ProSHADE_wignerMatrices.cpp.

188 {
189  //================================================ Report progress
190  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 4, "Start Wigner D matrix computation.", settings->messageShift );
191 
192  //================================================ For each band, find the Wigned d matrix
193  proshade_double *expARStart, *expAIStart, *expGRStart, *expGIStart;
194  proshade_double Dij, eARi, eAIi, eGRj, eGIj, iSign, rSign;
195  proshade_complex hlpVal;
196  proshade_unsign noOrders, arrConvIter;
197  for ( proshade_unsign bandIter = 0; bandIter < obj->getEMatDim ( ); bandIter++ )
198  {
199  //============================================ Initialise loop
200  noOrders = 2 * bandIter + 1;
201  arrConvIter = 0;
202  expARStart = &alphaExponentReal[ ( obj->getEMatDim ( ) - 1 ) - bandIter ];
203  expAIStart = &alphaExponentImag[ ( obj->getEMatDim ( ) - 1 ) - bandIter ];
204  expGRStart = &gammaExponentReal[ ( obj->getEMatDim ( ) - 1 ) - bandIter ];
205  expGIStart = &gammaExponentImag[ ( obj->getEMatDim ( ) - 1 ) - bandIter ];
206  iSign = 1.0;
207  rSign = 1.0;
208 
209  //============================================ Get wigner d matrix values using beta angles only
210  wignerdmat ( static_cast< int > ( bandIter ), matIn, matOut, trigs, sqrts, workspace );
211 
212  //============================================ Multiply the wigner d matrix by alpha and gamma values and save the wigner D matrix to output array
213  for ( proshade_unsign d1Iter = 0; d1Iter < noOrders; d1Iter++ )
214  {
215  eARi = expARStart[d1Iter];
216  eAIi = expAIStart[d1Iter];
217 
218  for ( proshade_unsign d2Iter = 0; d2Iter < noOrders; d2Iter++ )
219  {
220  Dij = matOut[arrConvIter];
221  eGRj = expGRStart[d2Iter];
222  eGIj = expGIStart[d2Iter];
223 
224  hlpVal[0] = ( Dij * eGRj * eARi - Dij * eGIj * eAIi ) * rSign;
225  hlpVal[1] = ( Dij * eGRj * eAIi + Dij * eGIj * eARi ) * iSign;
226  obj->setWignerMatrixValue ( hlpVal, bandIter, d1Iter, d2Iter );
227 
228  arrConvIter += 1;
229  iSign *= -1.0;
230  rSign *= -1.0;
231  }
232  }
233 
234  //============================================ Get ready for next wigner matrix calculation
235  memcpy ( matIn, matOut, sizeof ( proshade_double ) * ( noOrders * noOrders ) );
236  }
237 
238  //================================================ Report progress
239  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 5, "Wigner D matrices obtained.", settings->messageShift );
240 
241  //================================================ Done
242  return ;
243 
244 }

◆ computeWignerMatricesForRotation()

void ProSHADE_internal_wigner::computeWignerMatricesForRotation ( ProSHADE_settings settings,
ProSHADE_internal_data::ProSHADE_data obj,
proshade_double  eulerAlpha,
proshade_double  eulerBeta,
proshade_double  eulerGamma 
)

This function computes the Wigner D matrices for a particular set of Euler angles.

This function starts by allocating the required memory to store the Wigner D matrices for a particular object and then it proceeds to allocate all the computation memory as well. Subsequently, it prepares all the values needed for the computation and it calls the workhhorse computing function. Once complete, it deletes all the now redundant memory and exits.

Parameters
[in]settingsA pointer to settings class containing all the information required for the task.
[in]objA ProSHADE_data class object for which the Wigner matrices should be computed.
[in]eulerAlphaThe Euler ZYZ convention alpha angle value for the rotation in SO(3) space.
[in]eulerBetaThe Euler ZYZ convention beta angle value for the rotation in SO(3) space.
[in]eulerGammaThe Euler ZYZ convention gamma angle value for the rotation in SO(3) space.

Definition at line 258 of file ProSHADE_wignerMatrices.cpp.

259 {
260  //================================================ Initialise local variables
261  proshade_double *matIn, *matOut, *sqrts, *workspace, *alphaExponentReal, *alphaExponentImag, *gammaExponentReal, *gammaExponentImag, *trigs;
262 
263  //================================================ Allocate memory for Wigner matrices
265 
266  //================================================ Allocate the workspace memory
267  allocateWignerWorkspace ( matIn, matOut, sqrts, workspace, alphaExponentReal, alphaExponentImag,
268  gammaExponentReal, gammaExponentImag, trigs, obj->getEMatDim ( ) );
269 
270  //================================================ Prepare all values for the computation
271  prepareTrigsSqrtsAndExponents ( sqrts, alphaExponentReal, alphaExponentImag, gammaExponentReal, gammaExponentImag,
272  trigs, obj->getEMatDim ( ), eulerAlpha, eulerBeta, eulerGamma );
273 
274  //================================================ Compute the values
275  computeWignerMatrices ( settings, obj, alphaExponentReal, alphaExponentImag, gammaExponentReal, gammaExponentImag,
276  matIn, matOut, trigs, sqrts, workspace );
277 
278  //================================================ Release the workspace memory
279  releaseWignerWorkspace ( matIn, matOut, sqrts, workspace, alphaExponentReal, alphaExponentImag,
280  gammaExponentReal, gammaExponentImag, trigs );
281 
282  //================================================ Done
283  return ;
284 
285 }

◆ prepareTrigsSqrtsAndExponents()

void ProSHADE_internal_wigner::prepareTrigsSqrtsAndExponents ( proshade_double *  sqrts,
proshade_double *  alphaExponentReal,
proshade_double *  alphaExponentImag,
proshade_double *  gammaExponentReal,
proshade_double *  gammaExponentImag,
proshade_double *  trigs,
proshade_unsign  compBand,
proshade_double  angAlpha,
proshade_double  angBeta,
proshade_double  angGamma 
)

This function sets all the values repeatedly required for the computation.

Parameters
[in]sqrtsArray of square roots of the bands.
[in]alphaExponentRealAn array of exponents of the alpha angle for the real part of the Wigner matrices.
[in]alphaExponentImagAn array of exponents of the alpha angle for the imaginary part of the Wigner matrices.
[in]gammaExponentRealAn array of exponents of the gamma angle for the real part of the Wigner matrices.
[in]gammaExponentImagAn array of exponents of the gamma angle for the imaginary part of the Wigner matrices.
[in]trigsproshade_complex pointer which will hold the beta angle trigonometric function results.
[in]compBandThe bendwidth of the computation.
[in]angAlphaThe Euler alpha angle by which to rotate.
[in]angBetaThe Euler beta angle by which to rotate.
[in]angGammaThe Euler gamma angle by which to rotate.

Definition at line 147 of file ProSHADE_wignerMatrices.cpp.

148 {
149  //================================================ Compute the square roots
150  for ( proshade_unsign iter = 0; iter < ( 2 * compBand ); iter++ )
151  {
152  sqrts[iter] = static_cast<proshade_double> ( sqrt ( static_cast<proshade_double> ( iter ) ) );
153  }
154 
155  //================================================ Compute the trig values
156  trigs[0] = static_cast<proshade_double> ( cos ( 0.5 * -angBeta ) );
157  trigs[1] = static_cast<proshade_double> ( sin ( 0.5 * -angBeta ) );
158 
159  //================================================ Get alpha and gamma exponents
160  genExp ( static_cast< int > ( compBand ), angAlpha, alphaExponentReal, alphaExponentImag );
161  genExp ( static_cast< int > ( compBand ), angGamma, gammaExponentReal, gammaExponentImag );
162 
163  //================================================ Done
164  return ;
165 
166 }

◆ releaseWignerWorkspace()

void ProSHADE_internal_wigner::releaseWignerWorkspace ( proshade_double *&  matIn,
proshade_double *&  matOut,
proshade_double *&  sqrts,
proshade_double *&  workspace,
proshade_double *&  alphaExponentReal,
proshade_double *&  alphaExponentImag,
proshade_double *&  gammaExponentReal,
proshade_double *&  gammaExponentImag,
proshade_double *&  trigs 
)

This function releases the memory for the Wigner matrices computation.

Parameters
[in]matInA pointer to the array holding the inputs for Wigner d matrix computation by SOFT.
[in]matOutA pointer to the array holding the outputs for Wigner d matrix computation by SOFT.
[in]sqrtsArray of square roots of the bands.
[in]workspaceArray required by SOFT for internal computation space.
[in]alphaExponentRealAn array of exponents of the alpha angle for the real part of the Wigner matrices.
[in]alphaExponentImagAn array of exponents of the alpha angle for the imaginary part of the Wigner matrices.
[in]gammaExponentRealAn array of exponents of the gamma angle for the real part of the Wigner matrices.
[in]gammaExponentImagAn array of exponents of the gamma angle for the imaginary part of the Wigner matrices.

Definition at line 116 of file ProSHADE_wignerMatrices.cpp.

117 {
118  //================================================ Allocate the memory
119  if ( matIn != nullptr ) { delete[] matIn; }
120  if ( matOut != nullptr ) { delete[] matOut; }
121  if ( sqrts != nullptr ) { delete[] sqrts; }
122  if ( workspace != nullptr ) { delete[] workspace; }
123  if ( trigs != nullptr ) { delete[] trigs; }
124  if ( alphaExponentReal != nullptr ) { delete[] alphaExponentReal; }
125  if ( alphaExponentImag != nullptr ) { delete[] alphaExponentImag; }
126  if ( gammaExponentReal != nullptr ) { delete[] gammaExponentReal; }
127  if ( gammaExponentImag != nullptr ) { delete[] gammaExponentImag; }
128 
129  //================================================ Done
130  return ;
131 
132 }
ProSHADE_internal_wigner::prepareTrigsSqrtsAndExponents
void prepareTrigsSqrtsAndExponents(proshade_double *sqrts, proshade_double *alphaExponentReal, proshade_double *alphaExponentImag, proshade_double *gammaExponentReal, proshade_double *gammaExponentImag, proshade_double *trigs, proshade_unsign compBand, proshade_double angAlpha, proshade_double angBeta, proshade_double angGamma)
This function sets all the values repeatedly required for the computation.
Definition: ProSHADE_wignerMatrices.cpp:147
ProSHADE_internal_data::ProSHADE_data::setWignerMatrixValue
void setWignerMatrixValue(proshade_complex val, proshade_unsign band, proshade_unsign order1, proshade_unsign order2)
This function allows setting the Wigner D matrix value by its band, order1 and order2 co-ordinate.
Definition: ProSHADE_data.cpp:4388
ProSHADE_internal_wigner::releaseWignerWorkspace
void releaseWignerWorkspace(proshade_double *&matIn, proshade_double *&matOut, proshade_double *&sqrts, proshade_double *&workspace, proshade_double *&alphaExponentReal, proshade_double *&alphaExponentImag, proshade_double *&gammaExponentReal, proshade_double *&gammaExponentImag, proshade_double *&trigs)
This function releases the memory for the Wigner matrices computation.
Definition: ProSHADE_wignerMatrices.cpp:116
ProSHADE_internal_data::ProSHADE_data::allocateWignerMatricesSpace
void allocateWignerMatricesSpace()
This function allocates the memory for the Wigner matrices for the calling object.
Definition: ProSHADE_wignerMatrices.cpp:27
ProSHADE_internal_wigner::computeWignerMatrices
void computeWignerMatrices(ProSHADE_settings *settings, ProSHADE_internal_data::ProSHADE_data *obj, proshade_double *alphaExponentReal, proshade_double *alphaExponentImag, proshade_double *gammaExponentReal, proshade_double *gammaExponentImag, proshade_double *matIn, proshade_double *matOut, proshade_double *trigs, proshade_double *sqrts, proshade_double *workspace)
This function does the actual computation of the Wigner D matrices.
Definition: ProSHADE_wignerMatrices.cpp:187
ProSHADE_settings::verbose
proshade_signed verbose
Should the software report on the progress, or just be quiet? Value between -1 (nothing) and 4 (loud)
Definition: ProSHADE_settings.hpp:152
ProSHADE_settings::messageShift
proshade_signed messageShift
This value allows shifting the messages to create more readable log for sub-processes.
Definition: ProSHADE_settings.hpp:153
ProSHADE_internal_misc::checkMemoryAllocation
void checkMemoryAllocation(chVar checkVar, std::string fileP, unsigned int lineP, std::string funcP, std::string infoP="This error may occurs when ProSHADE requests memory to be\n : allocated to it and this operation fails. This could\n : happen when not enough memory is available, either due to\n : other processes using a lot of memory, or when the machine\n : does not have sufficient memory available. Re-run to see\n : if this problem persists.")
Checks if memory was allocated properly.
Definition: ProSHADE_misc.hpp:73
ProSHADE_internal_wigner::allocateWignerWorkspace
void allocateWignerWorkspace(proshade_double *&matIn, proshade_double *&matOut, proshade_double *&sqrts, proshade_double *&workspace, proshade_double *&alphaExponentReal, proshade_double *&alphaExponentImag, proshade_double *&gammaExponentReal, proshade_double *&gammaExponentImag, proshade_double *&trigs, proshade_unsign compBand)
This function allocates the memory for the Wigner matrices computation.
Definition: ProSHADE_wignerMatrices.cpp:75
ProSHADE_internal_data::ProSHADE_data::getEMatDim
proshade_unsign getEMatDim(void)
This function allows access to the maximum band for the E matrix.
Definition: ProSHADE_data.cpp:4014
ProSHADE_internal_messages::printProgressMessage
void printProgressMessage(proshade_signed verbose, proshade_signed messageLevel, std::string message, proshade_signed messageShift=0)
General stdout message printing.
Definition: ProSHADE_messages.cpp:71