Source Code Cross Referenced for Operator.java in  » Science » JSci » JSci » physics » quantum » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » JSci » JSci.physics.quantum 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package JSci.physics.quantum;
002:
003:        import JSci.maths.Complex;
004:        import JSci.maths.Member;
005:        import JSci.maths.DimensionException;
006:        import JSci.maths.MaximumIterationsExceededException;
007:        import JSci.maths.matrices.AbstractComplexSquareMatrix;
008:        import JSci.maths.vectors.AbstractComplexVector;
009:        import JSci.maths.vectors.ComplexVector;
010:
011:        /**
012:         * The Operator class provides an object for encapsulating quantum mechanical operators.
013:         * @version 1.5
014:         * @author Mark Hale
015:         */
016:        public class Operator implements  Member {
017:            protected AbstractComplexSquareMatrix representation;
018:
019:            /**
020:             * Constructs an operator given a matrix representation.
021:             * @param rep a matrix representation
022:             */
023:            public Operator(AbstractComplexSquareMatrix rep) {
024:                representation = rep;
025:            }
026:
027:            /**
028:             * Compares two operators for equality.
029:             * @param a an operator
030:             */
031:            public boolean equals(Object a) {
032:                return representation.equals(((Operator) a).representation);
033:            }
034:
035:            /**
036:             * Returns a string representing this operator.
037:             */
038:            public String toString() {
039:                return representation.toString();
040:            }
041:
042:            /**
043:             * Returns a hashcode for this operator.
044:             */
045:            public int hashCode() {
046:                return (int) Math.exp(trace().mod());
047:            }
048:
049:            /**
050:             * Returns the representation.
051:             */
052:            public AbstractComplexSquareMatrix getRepresentation() {
053:                return representation;
054:            }
055:
056:            /**
057:             * Returns true if this operator is self-adjoint.
058:             */
059:            public boolean isSelfAdjoint() {
060:                return representation.isHermitian();
061:            }
062:
063:            /**
064:             * Returns true if this operator is unitary.
065:             */
066:            public boolean isUnitary() {
067:                return representation.isUnitary();
068:            }
069:
070:            /**
071:             * Returns the trace.
072:             */
073:            public Complex trace() {
074:                return representation.trace();
075:            }
076:
077:            /**
078:             * Returns the operator norm.
079:             */
080:            public double norm() {
081:                try {
082:                    return representation.operatorNorm();
083:                } catch (MaximumIterationsExceededException e) {
084:                    return -1.0;
085:                }
086:            }
087:
088:            /**
089:             * Returns the dimension.
090:             */
091:            public int dimension() {
092:                return representation.columns();
093:            }
094:
095:            public Object getSet() {
096:                return representation.getSet();
097:            }
098:
099:            //============
100:            // OPERATIONS
101:            //============
102:
103:            // ADDITION
104:
105:            /**
106:             * Returns the addition of this operator and another.
107:             * @param op an operator
108:             * @exception MatrixDimensionException If the operators have different dimensions.
109:             */
110:            public Operator add(Operator op) {
111:                return new Operator(representation.add(op.representation));
112:            }
113:
114:            // SUBTRACTION
115:
116:            /**
117:             * Returns the subtraction of this operator and another.
118:             * @param op an operator
119:             * @exception MatrixDimensionException If the operators have different dimensions.
120:             */
121:            public Operator subtract(Operator op) {
122:                return new Operator(representation.subtract(op.representation));
123:            }
124:
125:            // MULTIPLICATION
126:
127:            /**
128:             * Returns the multiplication of this operator and another.
129:             * @param op an operator
130:             * @exception MatrixDimensionException If the operators have different dimensions.
131:             */
132:            public Operator multiply(Operator op) {
133:                return new Operator(representation.multiply(op.representation));
134:            }
135:
136:            /**
137:             * Returns the multiplication of this operator and a ket vector.
138:             * @param ket a ket vector
139:             * @exception DimensionException If the operator and vector have different dimensions.
140:             */
141:            public KetVector multiply(KetVector ket) {
142:                int opDim = dimension();
143:                if (opDim == ket.dimension()) {
144:                    AbstractComplexVector ketRep = ket.getRepresentation();
145:                    Complex tmp, array[] = new Complex[opDim];
146:                    for (int j, i = 0; i < opDim; i++) {
147:                        tmp = representation.getElement(i, 0).multiply(
148:                                ketRep.getComponent(0));
149:                        for (j = 1; j < opDim; j++)
150:                            tmp = tmp.add(representation.getElement(i, j)
151:                                    .multiply(ketRep.getComponent(j)));
152:                        array[i] = tmp;
153:                    }
154:                    return new KetVector(new ComplexVector(array));
155:                } else
156:                    throw new DimensionException(
157:                            "Operator and vector have different dimensions.");
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.