Cloude.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2004 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Util/units/Cloude.h
10
11#ifndef __Cloude_H
12#define __Cloude_H
13
14#include "Pauli.h"
15#include "Matrix.h"
16
18/* This method computes the hermitian target coherency matrix, derived from
19 the input Jones matrix as described by equations 4.6 and 4.9 of
20
21 Cloude, S.R., 1986, "Group theory and polarization algebra",
22 Optik, 75(1), 26-36
23*/
24template<typename T>
25Matrix< 4,4, std::complex<T> > coherence (const Jones<T>& jones)
26{
27 // form the Hermitian biquaternion (Eq. 4.6)
28 Quaternion<std::complex<T>,Hermitian> q = convert(jones);
29
30 // convert to the equivalent complex vector and its Hermitian transpose
33
34 for (unsigned i=0; i<4; i++) {
35 vect[i] = q[i];
36 herm[i] = conj(q[i]);
37 }
38
39 // Eq. 4.9
40 return outer(vect,herm);
41}
42
43
45template<typename T>
46Matrix< 4,4, std::complex<T> > coherence (const Jones<T>& J,
47 const Jones<T>& Jgrad)
48{
49 // form the Hermitian biquaternion (Eq. 4.6)
50 Quaternion<std::complex<T>,Hermitian> q = convert( J );
51 Quaternion<std::complex<T>,Hermitian> qgrad = convert( Jgrad );
52
53 // convert to the equivalent complex vector and its Hermitian transpose
56
59
60 for (unsigned i=0; i<4; i++)
61 {
62 v[i] = q[i];
63 h[i] = conj(q[i]);
64
65 vgrad[i] = qgrad[i];
66 hgrad[i] = conj(qgrad[i]);
67 }
68
69 return outer(v,hgrad) + outer(vgrad,h);
70}
71
73/* The left eigenvector, as returned by Jacobi, is the row vector
74 given by the hermitian transpose of the right (column)
75 eigenvector. */
76template<typename T>
77Jones<T> system (const Vector< 4,std::complex<T> >& left_eigen)
78{
79 Quaternion<std::complex<T>,Hermitian> q;
80
81 for (unsigned idim=0; idim<4; idim++)
82 q[idim] = conj( left_eigen[idim] );
83
84 return convert (q);
85}
86
88
90template<unsigned N, typename T>
91 double entropy (const Vector<N,T>& eigenvalues)
92{
93 unsigned i;
94 double total = 0;
95
96 for (i=0; i<N; i++)
97 total += eigenvalues[i];
98
99 double entropy = 0;
100 for (i=0; i<N; i++) {
101 double Pi = eigenvalues[i]/total;
102 entropy -= Pi * log(Pi)/log(double(N));
103 }
104
105 return entropy;
106}
107
108#endif

Generated using doxygen 1.14.0