Package xal.tools.beam
Class PhaseVector
- All Implemented Interfaces:
Serializable
,IArchive
Class
.- Since:
- Oct 11, 2013
- Author:
- Christopher K. Allen
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumeration for the element position indices for homogeneous phase space objects. -
Field Summary
Fields inherited from class xal.tools.math.BaseVector
ATTR_DATA
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of PhaseVector with zero initial value.PhaseVector
(double[] arrVals) Create a new instance of PhaseVector with specified initial value.PhaseVector
(double x, double xp, double y, double yp, double z, double zp) Create a new instance ofPhaseVector
with specified initial value.PhaseVector
(String strTokens) Create a new instance of PhaseVector with specified initial value specified by the formatted string argument.PhaseVector
(PhaseVector vecInit) Copy Constructor Creates newPhaseVector
object which is a deep copy of the given argument.PhaseVector
(DataAdaptor daSource) Create a newPhaseVector
object and initialize it with the data behind theDataAdaptor
data source.PhaseVector
(R3 vecPos, R3 vecMom) Create a new instance of PhaseVector with specified initial value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
We need to redefine this method in order to set the homogeneous coordinate back to unity.clone()
Creates and returns a deep copy of this vector.static PhaseVector
copy
(PhaseVector vecParent) Creates a deep copy of the givenPhaseVector
object.static PhaseVector
Embeds the given vector z ∈ R4 into homogeneous phase space.static PhaseVector
Embeds the given vector z ∈ R6 into homogeneous phase space.Get momentum coordinate in R3.Get position coordinates in R3.double
getx()
Return the x position coordinatedouble
getxp()
Return the x momentum coordinatedouble
gety()
Return the y position coordinatedouble
getyp()
Return the y momentum coordinatedouble
getz()
Return the z momentum coordinatedouble
getzp()
Return the z momentum coordinatedouble
Must override to account for the homogeneous coordinate.static PhaseVector
loadFrom
(DataAdaptor daSource) Create a newPhaseVector
object and initialize with the data source behind the givenDataAdaptor
interface.static void
Test driverminus
(PhaseVector vecSub) Must override to protect the homogeneous coordinate.void
minusEquals
(PhaseVector vecSub) Must override to protect the homogeneous coordinate.negate()
Must override to protect the homogeneous coordinate.void
Must override to protect the homogeneous coordinate.protected PhaseVector
newInstance
(double[] arrVecInt) Creates a new instance of this vector type with the given Java array as the internal representation.protected PhaseVector
newInstance
(int size) Handles object creation required by the base class.static PhaseVector
newZero()
Create a new instance of a zero phase vector.double
norm1()
Return the l1 norm of the vector.double
norm2()
Return the l2 norm of the vector.double
normInf()
Return the l∞ norm of the vector.outerProd
(PhaseVector vec) Vector outer product operation.static PhaseVector
Create a new instance of PhaseVector with initial value determined by the formatted string argument.plus
(PhaseVector vecAdd) Must override to protect the homogeneous coordinate.void
plusEquals
(PhaseVector vecAdd) Must override to protect the homogeneous coordinate.void
print
(PrintWriter os) Print the vector contents to an output stream, does not add new line.void
println
(PrintWriter os) Print the vector contents to an output stream, add new line character.Print the vector contents to a String.void
setVector
(double[] arrVector) Must override this method to ignore any missing homogeneous coordinate since it is understood that this value is always there and unchanging.void
Must override this method to ignore any missing homogeneous coordinate since it is understood that this value is always there and unchanging.void
setx
(double dblVal) Set the x position coordinatevoid
setxp
(double dblVal) Set the x momentum coordinatevoid
sety
(double dblVal) Set the y position coordinatevoid
setyp
(double dblVal) Set the y momentum coordinatevoid
setz
(double dblVal) Set the z position coordinatevoid
setzp
(double dblVal) Set the z momentum coordinatetimes
(double s) Must override to protect the homogeneous coordinate.void
timesEquals
(double s) Must override to protect the homogeneous coordinate.Methods inherited from class xal.tools.math.BaseVector
assignUnity, copyVector, embedIn, equals, getArrayCopy, getElem, getElem, getSize, getVector, hashCode, isEquivalentTo, leftMultiply, load, newInstance, print, projectOnto, rightMultiply, save, setElem, setElem, setVector, toString
-
Constructor Details
-
PhaseVector
public PhaseVector()Creates a new instance of PhaseVector with zero initial value. -
PhaseVector
public PhaseVector(double x, double xp, double y, double yp, double z, double zp) Create a new instance ofPhaseVector
with specified initial value.- Parameters:
x
- x-plane positionxp
- x-plane momentumy
- y-plane positionyp
- y-plane momentumz
- z-plane positionzp
- z-plane momentum
-
PhaseVector
Copy Constructor Creates newPhaseVector
object which is a deep copy of the given argument.- Parameters:
vecInit
- initial value
-
PhaseVector
public PhaseVector(double[] arrVals) Create a new instance of PhaseVector with specified initial value.- Parameters:
arrVals
- length 6 array of initial values- Throws:
IllegalArgumentException
- argument must be a length-six array
-
PhaseVector
Create a new instance of PhaseVector with specified initial value.- Parameters:
vecPos
- position vector (x,y,z) in R3vecMom
- momentum vector (xp, yp, zp) in R3
-
PhaseVector
Create a newPhaseVector
object and initialize it with the data behind theDataAdaptor
data source.- Parameters:
daSource
- data source containing initialization data- Throws:
DataFormatException
- malformed data- See Also:
-
PhaseVector
Create a new instance of PhaseVector with specified initial value specified by the formatted string argument. The input string may or may not contain the final coordinate which always has value 1. The string should be formatted as "(x,x',y,y',z,zp')" where x, x', y, y', z, z' are floating point representations.- Parameters:
strTokens
- token string representing values phase coordinates- Throws:
IllegalArgumentException
- wrong number of tokens in argument (must be 6 or 7)NumberFormatException
- bad numeric value, un-parseable- See Also:
-
-
Method Details
-
newZero
Create a new instance of a zero phase vector.- Returns:
- zero vector
-
copy
Creates a deep copy of the givenPhaseVector
object. Thus, the argument is unmodified and unreferenced.- Parameters:
vecParent
- vector object to clone- Returns:
- deep copy of the argument
-
parse
public static PhaseVector parse(String strTokens) throws NumberFormatException, IllegalArgumentException Create a new instance of PhaseVector with initial value determined by the formatted string argument. The string should be formatted as "(x,x',y,y',z,zp')" where x, x', y, y', z, z' are floating point representations.- Parameters:
strTokens
- six-token string representing values phase coordinates- Throws:
IllegalArgumentException
- wrong number of tokens in argument (must be 6)NumberFormatException
- bad numeric value, unparseable
-
loadFrom
Create a newPhaseVector
object and initialize with the data source behind the givenDataAdaptor
interface.- Parameters:
daSource
- data source containing initialization data- Throws:
DataFormatException
- malformed data- Since:
- Jan 4, 2016, Christopher K. Allen
- See Also:
-
embed
Embeds the given vector z ∈ R6 into homogeneous phase space. The given vector is treated like a vector of phase space coordinates corresponding to the first 6 elements of aPhaseVector
object. The last element of the returned phase vector has value 1, as do all phase vectors.- Parameters:
vecCoords
- vector z containing the first 6 element values of the returned phase vector- Returns:
- the augmented vector (z,1)
- Since:
- Oct 16, 2013
-
embed
Embeds the given vector z ∈ R4 into homogeneous phase space. The given vector is treated like a vector of transverse phase space coordinates corresponding to the first 4 elements of aPhaseVector
object. The vector elements corresponding to the longitudinal phase space coordinates z and z' are both set to zero. The last element of the returned phase vector has value 1, as do all phase vectors.- Parameters:
vecCoords
- vector z containing the first 6 element values of the returned phase vector- Returns:
- the augmented vector (z,1)
- Since:
- Oct 16, 2013
-
setVector
Must override this method to ignore any missing homogeneous coordinate since it is understood that this value is always there and unchanging.- Overrides:
setVector
in classBaseVector<PhaseVector>
- Parameters:
strValues
- token vector of SIZE2 numeric values- Since:
- Sep 6, 2014
- See Also:
-
setVector
Must override this method to ignore any missing homogeneous coordinate since it is understood that this value is always there and unchanging.- Overrides:
setVector
in classBaseVector<PhaseVector>
- Parameters:
arrVector
- Java primitive array containing new vector values- Throws:
IllegalArgumentException
- the argument must have the same dimensions as this matrix- Since:
- Sep 6, 2014
- See Also:
-
setx
public void setx(double dblVal) Set the x position coordinate -
setxp
public void setxp(double dblVal) Set the x momentum coordinate -
sety
public void sety(double dblVal) Set the y position coordinate -
setyp
public void setyp(double dblVal) Set the y momentum coordinate -
setz
public void setz(double dblVal) Set the z position coordinate -
setzp
public void setzp(double dblVal) Set the z momentum coordinate -
getx
public double getx()Return the x position coordinate -
getxp
public double getxp()Return the x momentum coordinate -
gety
public double gety()Return the y position coordinate -
getyp
public double getyp()Return the y momentum coordinate -
getz
public double getz()Return the z momentum coordinate -
getzp
public double getzp()Return the z momentum coordinate -
getPosition
Get position coordinates in R3.- Returns:
- (x,y,z)
-
getMomentum
Get momentum coordinate in R3.- Returns:
- (xp,yp,zp)
-
outerProd
Vector outer product operation. Returns the tensor outer product as aPhaseMatrix
object- Parameters:
vec
- second argument to tensor product- Returns:
- outer product = [ this_i*vec_j ]
-
newInstance
Handles object creation required by the base class.- Specified by:
newInstance
in classBaseVector<PhaseVector>
- Returns:
- uninitialized vector object of type
V
- Since:
- Jun 17, 2014
- See Also:
-
xal.tools.math.BaseVector#newInstance()
-
newInstance
Description copied from class:BaseVector
Creates a new instance of this vector type with the given Java array as the internal representation.- Specified by:
newInstance
in classBaseVector<PhaseVector>
- Parameters:
arrVecInt
- new vector's guts- Returns:
- new instance of this vector type with the internal representation
- Since:
- Jul 24, 2015 by Christopher K. Allen
- See Also:
-
assignZero
public void assignZero()We need to redefine this method in order to set the homogeneous coordinate back to unity.- Overrides:
assignZero
in classBaseVector<PhaseVector>
- Since:
- Nov 6, 2014
- See Also:
-
negate
Must override to protect the homogeneous coordinate.- Overrides:
negate
in classBaseVector<PhaseVector>
- Returns:
- antipodal vector of the current object
- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
negateEquals
public void negateEquals()Must override to protect the homogeneous coordinate.- Overrides:
negateEquals
in classBaseVector<PhaseVector>
- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
plusEquals
Must override to protect the homogeneous coordinate.- Overrides:
plusEquals
in classBaseVector<PhaseVector>
- Parameters:
vecAdd
- Vector to add to this vector (addend)- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
plus
Must override to protect the homogeneous coordinate.- Overrides:
plus
in classBaseVector<PhaseVector>
- Parameters:
vecAdd
- vector added to this one (addend)- Returns:
- sum of this vector and given vector,
- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
minusEquals
Must override to protect the homogeneous coordinate.- Overrides:
minusEquals
in classBaseVector<PhaseVector>
- Parameters:
vecSub
- Vector to subtract from this vector (subtrahend)- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
minus
Must override to protect the homogeneous coordinate.- Overrides:
minus
in classBaseVector<PhaseVector>
- Parameters:
vecSub
- vector subtracted from this one (subtrahend)- Returns:
- difference of this vector and the given vector,
- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
times
Must override to protect the homogeneous coordinate.- Overrides:
times
in classBaseVector<PhaseVector>
- Parameters:
s
- scalar value- Returns:
- result of scalar multiplication
- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
timesEquals
public void timesEquals(double s) Must override to protect the homogeneous coordinate.- Overrides:
timesEquals
in classBaseVector<PhaseVector>
- Parameters:
s
- scalar- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
innerProd
Must override to account for the homogeneous coordinate.- Overrides:
innerProd
in classBaseVector<PhaseVector>
- Parameters:
v
- second vector- Returns:
- inner product of this vector and argument
- Throws:
IllegalArgumentException
- Since:
- Jan 7, 2015 by Christopher K. Allen
- See Also:
-
norm1
public double norm1()Return the l1 norm of the vector. Must override to account for the projective coordinate.- Overrides:
norm1
in classBaseVector<PhaseVector>
- Returns:
- ||z||1 = Σi≠6 |zi|
- Since:
- Oct 11, 2013
- See Also:
-
norm2
public double norm2()Return the l2 norm of the vector. Must override to account for the projective coordinate.- Overrides:
norm2
in classBaseVector<PhaseVector>
- Returns:
- ||z||2 = [ Σi≠6 zi2 ]1/2
- Since:
- Oct 11, 2013
- See Also:
-
normInf
public double normInf()Return the l∞ norm of the vector. Must override to account for the projective coordinate.- Overrides:
normInf
in classBaseVector<PhaseVector>
- Returns:
- ||z||∞ = supi≠6 |zi|
- Since:
- Oct 11, 2013
- See Also:
-
clone
Creates and returns a deep copy of this vector.- Specified by:
clone
in classBaseVector<PhaseVector>
- Since:
- Jul 3, 2014
- See Also:
-
print
Print the vector contents to an output stream, does not add new line.- Overrides:
print
in classBaseVector<PhaseVector>
- Parameters:
os
- output stream object
-
println
Print the vector contents to an output stream, add new line character.- Overrides:
println
in classBaseVector<PhaseVector>
- Parameters:
os
- output stream object
-
printString
Print the vector contents to a String. -
main
Test driver
-