40 throw "wrong dimension";
63 for (
int idx=0; idx<
dim*(
dim-1)/2; idx++) {
64 vargamma[idx] = (2*double(rand())/double(RAND_MAX)-1)*2*M_PI;
87 std::stringstream sstream;
93 sstream <<
"Wring number of parameters in Random_Orthogonal::Construct_Orthogonal_Matrix" << std::endl;
95 print(sstream, verbose_level);
101 memset( vargamma_mtx.
get_data(), 0.0, vargamma_mtx.
size()*
sizeof(double) );
103 for (
int idx=0; idx<
dim; idx++) {
104 for (
int jdx=idx+1; jdx<
dim; jdx++) {
105 vargamma_mtx[idx*vargamma_mtx.
stride + jdx] = vargamma[gamma_index];
153 for (
int ndx=2; ndx<=
dim; ndx++) {
161 for (
int row_idx=0; row_idx<ndx-1; row_idx++) {
164 tn[ndx*tn.
stride -1] = 1.0;
167 for (
int col_idx=0; col_idx<ndx; col_idx++) {
173 sl[0] = -tn[col_idx*tn.stride + ndx-1];
176 Tn_new[col_idx] = tn[col_idx]*cos(vargamma_mtx[ndx-1]) - sl[0]*sin(vargamma_mtx[ndx-1]);
179 for (
int row_idx=1; row_idx<ndx; row_idx++) {
182 sl[row_idx] = tn[kdx*tn.stride+col_idx] * sin(vargamma_mtx[kdx*dim+ndx-1]) + sl[kdx] * cos(vargamma_mtx[kdx*dim+ndx-1]);
184 if ( row_idx == ndx-1 ) {
185 Tn_new[row_idx*Tn_new.
stride + col_idx] = - sl[row_idx];
188 Tn_new[row_idx*Tn_new.
stride + col_idx] = tn[row_idx*tn.stride + col_idx] * cos(vargamma_mtx[row_idx*dim+ndx-1]) - sl[row_idx] * sin(vargamma_mtx[row_idx*dim+ndx-1]);
204 for (
int idx=0; idx<ret.
size(); idx++) {
205 ret[idx].real = Tn[idx];
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
int stride
The column stride of the array. (The array elements in one row are a_0, a_1, ... a_{cols-1}, 0, 0, 0, 0. The number of zeros is stride-cols)
Random_Orthogonal(int dim_in)
Constructor of the class.
Header file for a class containing basic methods for setting up the verbosity level.
scalar * get_data() const
Call to get the pointer to the stored data.
int rows
The number of rows.
int cols
The number of columns.
Umtx
The unitary to be decomposed.
Matrix Construct_Orthogonal_Matrix()
Call to create a random unitary.
Class to store data of complex arrays and its properties.
int size() const
Call to get the number of the allocated elements.
int dim
The number of rows in the created unitary.
Class to store data of complex arrays and its properties.