Source Code Cross Referenced for BraVector.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.vectors.MathVector;
005:        import JSci.maths.vectors.AbstractComplexVector;
006:        import JSci.maths.vectors.ComplexVector;
007:        import JSci.maths.matrices.AbstractComplexSquareMatrix;
008:        import JSci.maths.DimensionException;
009:        import JSci.maths.vectors.VectorDimensionException;
010:        import JSci.maths.groups.AbelianGroup;
011:        import JSci.maths.algebras.Module;
012:        import JSci.maths.fields.Ring;
013:
014:        /**
015:         * The BraVector class provides an object for encapsulating Dirac bra vectors.
016:         * @version 1.5
017:         * @author Mark Hale
018:         */
019:        public final class BraVector extends MathVector {
020:            private AbstractComplexVector representation;
021:
022:            /**
023:             * Constructs a bra vector given a vector representation.
024:             * @param rep a vector representation
025:             */
026:            public BraVector(AbstractComplexVector rep) {
027:                super (rep.dimension());
028:                representation = rep;
029:            }
030:
031:            /**
032:             * Compares two bra vectors for equality.
033:             * @param a a bra vector
034:             */
035:            public boolean equals(Object a) {
036:                return representation.equals(((BraVector) a).representation);
037:            }
038:
039:            /**
040:             * Returns a comma delimited string representing the value of this bra vector.
041:             */
042:            public String toString() {
043:                return representation.toString();
044:            }
045:
046:            /**
047:             * Returns a hashcode for this bra vector.
048:             */
049:            public int hashCode() {
050:                return representation.hashCode();
051:            }
052:
053:            /**
054:             * Map this bra vector to a ket vector.
055:             */
056:            public KetVector toKetVector() {
057:                return new KetVector(representation.conjugate());
058:            }
059:
060:            /**
061:             * Returns the representation.
062:             */
063:            public AbstractComplexVector getRepresentation() {
064:                return representation;
065:            }
066:
067:            /**
068:             * Returns the norm.
069:             */
070:            public double norm() {
071:                return representation.norm();
072:            }
073:
074:            public Object getSet() {
075:                return representation.getSet();
076:            }
077:
078:            //============
079:            // OPERATIONS
080:            //============
081:
082:            /**
083:             * Returns the negative of this vector.
084:             */
085:            public AbelianGroup.Member negate() {
086:                return representation.negate();
087:            }
088:
089:            // ADDITION
090:
091:            /**
092:             * Returns the addition of this vector and another.
093:             */
094:            public AbelianGroup.Member add(AbelianGroup.Member v) {
095:                if (v instanceof  BraVector)
096:                    return add((BraVector) v);
097:                else
098:                    throw new IllegalArgumentException(
099:                            "Vector class not recognised by this method.");
100:            }
101:
102:            /**
103:             * Returns the addition of this vector and another.
104:             * @param v a bra vector
105:             * @exception VectorDimensionException If the vectors are different sizes.
106:             */
107:            public BraVector add(BraVector v) {
108:                return new BraVector(representation.add(v.representation));
109:            }
110:
111:            // SUBTRACTION
112:
113:            /**
114:             * Returns the subtraction of this vector by another.
115:             */
116:            public AbelianGroup.Member subtract(AbelianGroup.Member v) {
117:                if (v instanceof  BraVector)
118:                    return subtract((BraVector) v);
119:                else
120:                    throw new IllegalArgumentException(
121:                            "Vector class not recognised by this method.");
122:            }
123:
124:            /**
125:             * Returns the subtraction of this vector by another.
126:             * @param v a bra vector
127:             * @exception VectorDimensionException If the vectors are different sizes.
128:             */
129:            public BraVector subtract(BraVector v) {
130:                return new BraVector(representation.subtract(v.representation));
131:            }
132:
133:            // MULTIPLICATION
134:
135:            /**
136:             * Returns the multiplication of this bra vector by a scalar.
137:             */
138:            public Module.Member scalarMultiply(Ring.Member x) {
139:                return representation.scalarMultiply(x);
140:            }
141:
142:            /**
143:             * Returns the multiplication of this bra vector and a ket vector.
144:             * @param ket a ket vector
145:             * @exception VectorDimensionException If the vectors have different dimensions.
146:             */
147:            public Complex multiply(KetVector ket) {
148:                final int braDim = dimension();
149:                if (braDim == ket.dimension()) {
150:                    AbstractComplexVector ketRep = ket.getRepresentation();
151:                    Complex answer = representation.getComponent(0).multiply(
152:                            ketRep.getComponent(0));
153:                    for (int i = 1; i < braDim; i++)
154:                        answer = answer.add(representation.getComponent(i)
155:                                .multiply(ketRep.getComponent(i)));
156:                    return answer;
157:                } else
158:                    throw new VectorDimensionException(
159:                            "Vectors have different dimensions.");
160:            }
161:
162:            /**
163:             * Returns the multiplication of this bra vector and an operator.
164:             * @param op an operator
165:             * @exception DimensionException If the operator and vector have different dimensions.
166:             */
167:            public BraVector multiply(Operator op) {
168:                final int braDim = dimension();
169:                if (braDim == op.dimension()) {
170:                    AbstractComplexSquareMatrix opRep = op.getRepresentation();
171:                    Complex tmp, array[] = new Complex[braDim];
172:                    for (int j, i = 0; i < braDim; i++) {
173:                        tmp = representation.getComponent(0).multiply(
174:                                opRep.getElement(0, i));
175:                        for (j = 1; j < braDim; j++)
176:                            tmp = tmp.add(representation.getComponent(j)
177:                                    .multiply(opRep.getElement(j, i)));
178:                        array[i] = tmp;
179:                    }
180:                    return new BraVector(new ComplexVector(array));
181:                } else
182:                    throw new DimensionException(
183:                            "Operator and vector have different dimensions.");
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.