Element transformation
Three of them are mere convenience functions that apply a transformation for single complex numbers to each element of the container:
ublas::vector<std::complex<double> > v1(6); for(int i = 0; i < 6; ++i) { v1[i] = std::complex<double> (i, i * -1.0); } std::cout << v1 << std::endl; ublas::matrix<std::complex<double> > m1(6,3); for(unsigned int i = 0; i < m1.size1(); ++i) for(unsigned int j = 0; j < m1.size2(); ++j) m1(i, j) = std::complex<double>(i, j * -1.0); std::cout << m1 << std::endl; std::cout << " conjugate vector: " << ublas::conj(v1) << std::endl; // 1 std::cout << " conjugate matrix: " << ublas::conj(m1) << std::endl; std::cout << " real vector: " << ublas::real(v1) << std::endl; // 2 std::cout << " real matrix: " << ublas::real(m1) << std::endl; std::cout << " imaginary vector: " << ublas::imag(v1) << std::endl; // 3 std::cout << " imaginary matrix: " << ublas::imag(m1) << std::endl;1. The conjugate of a complex number is another complex with the same real part and the imaginary part with the changed sign. The uBLAS conj() function returns a new container where each element is the conjugate of the same element in the original container.
2. A complex number has two components, real and imaginary. The uBLAS real() function returns a container where each element is the real part of the correspondent complex element in the original container.
3. Counterpart of (2), here the container in out contains the imaginary parts of the original complex numbers.
Matrix transposition
The other two functions could still be used on both vectors or matrices, even though they make actual sense only on the latter.
std::cout << " transpose vector: " << ublas::trans(v1) << std::endl; // 1 std::cout << " transpose matrix: " << ublas::trans(m1) << std::endl; std::cout << " hermitian vector: " << ublas::herm(v1) << std::endl; // 2 std::cout << " hermitian matrix: " << ublas::herm(m1) << std::endl;1. A transpose of a matrix is another matrix where the rows of the first are the columns of the second. A vector is a matrix with just one row, so there is no change.
2. The Hermitian matrix is another matrix, transpose of the conjugate of the original one. When applied to a vector, the Hermitian generates the conjugated vector.
No comments:
Post a Comment