tensor(deprecated)/compare - Help

tensor

 compare
 compare two objects each of which can be a tensor_type, spin coefficient table or a curvature component table.

 Calling Sequence compare( U, V)

Parameters

 U, V - U and V can be any of tensor_type, spin coefficient table or curvature component table. See the help file for the tensor package for the explanation of the structures of the three types of objects mentioned above.

Description

Important: The tensor package has been deprecated. Use the superseding packages DifferentialGeometry and Physics instead.

 • This function compares the input parameters U and V with the restriction that both of them must be one of the three recognized structures.
 • If they are not of the same structure, then this routine reports the structure each has.
 • If they are both spin coefficient tables or both curvature component table, then the routine compares each pair of corresponding elements of U and V, and returns the sequence of indices of unmatching elements.
 • If U and V are both tensor_types, then this routine first compares their ranks, dimensions, then characters and returns an appropriate flag if detects any distinction.  If U and V share the same rank, dimension, and character then compare() goes on to compare each "independently defined" corresponding pair of components of the two tensor_types as well as the indexing functions of the component arrays. compare() then returns the sequence of the indices of the unmatching components, and the name 'indexfunc' if the two component arrays have different indexing functions.
 • The name 'Identical' is returned if U and V are found identical in each aspect checked.
 • Simplification :
 – compare() has one simplifier, tensor/compare/simp, used to simplify the difference of each pair of corresponding components/elements of the two objects being compared.  The simplified difference is then checked if vanishing or not.
 tensor/compare/simp is initialized to tensor/simp, but it is recommended that it be customized to suit the needs of a particular comparison.
 • Caution :  When compare() reports that two objects differ in a set of their components/elements, what it really means is that the employed simplifier fails to simplify the pairwise differences of those reported components.  The user is hence advised to double check with another simplifier (more powerful presumably) or by inspecting each pair of the reported components.
 • This function is part of the tensor package, and can be used in the form compare(..) only after performing the command with(tensor), or with(tensor, compare).  The function can always be accessed in the long form tensor[compare].

Examples

Important: The tensor package has been deprecated. Use the superseding packages DifferentialGeometry and Physics instead.

 > $\mathrm{with}\left(\mathrm{tensor}\right):$
 > $\mathrm{I3}≔\mathrm{array}\left(\mathrm{identity},1..3,1..3\right):$
 > $\mathrm{I4}≔\mathrm{array}\left(\mathrm{identity},1..4,1..4\right):$
 > $U≔\mathrm{create}\left(\left[1,1\right],\mathrm{op}\left(\mathrm{I3}\right)\right)$
 ${U}{:=}{\mathrm{table}}\left(\left[{\mathrm{compts}}{=}\left[\begin{array}{rrr}{1}& {0}& {0}\\ {0}& {1}& {0}\\ {0}& {0}& {1}\end{array}\right]{,}{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]\right]\right)$ (1)
 > $\mathrm{compare}\left(U,U\right)$
 ${\mathrm{Identical}}$ (2)
 > $V≔\mathrm{create}\left(\left[1,1\right],\mathrm{op}\left(\mathrm{I4}\right)\right)$
 ${V}{:=}{\mathrm{table}}\left(\left[{\mathrm{compts}}{=}\left[\begin{array}{rrrr}{1}& {0}& {0}& {0}\\ {0}& {1}& {0}& {0}\\ {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {1}\end{array}\right]{,}{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]\right]\right)$ (3)
 > $\mathrm{compare}\left(U,V\right)$
 ${\mathrm{Dimensions unmatched}}$ (4)
 > $Z≔\mathrm{create}\left(\left[1,1\right],\mathrm{array}\left(\mathrm{sparse},1..4,1..4\right)\right)$
 ${Z}{:=}{\mathrm{table}}\left(\left[{\mathrm{compts}}{=}\left[\begin{array}{rrrr}{0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\end{array}\right]{,}{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]\right]\right)$ (5)
 > $\mathrm{compare}\left(V,Z\right)$
 ${\mathrm{indexfunc}}$ (6)

Note here that neither V nor Z has independently defined components. The various 0's and 1's in the two tensor_types come from the respective indexing functions in the component arrays and that is why compare() only returns indexfunc. See the following example for more details.

 > $\mathrm{T_compts}≔\mathrm{array}\left(\mathrm{symmetric},1..3,1..3,\left[\left(1,1\right)=x,\left(2,2\right)=y,\left(3,3\right)=z,\left(1,2\right)=0,\left(1,3\right)=0,\left(2,3\right)=0\right]\right):$
 > $T≔\mathrm{create}\left(\left[1,1\right],\mathrm{op}\left(\mathrm{T_compts}\right)\right)$
 ${T}{:=}{\mathrm{table}}\left(\left[{\mathrm{compts}}{=}\left[\begin{array}{ccc}{x}& {0}& {0}\\ {0}& {y}& {0}\\ {0}& {0}& {z}\end{array}\right]{,}{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]\right]\right)$ (7)
 > $\mathrm{compare}\left(T,U\right)$
 ${\mathrm{indexfunc}}{,}\left[{1}{,}{1}\right]{,}\left[{2}{,}{2}\right]{,}\left[{3}{,}{3}\right]$ (8)
 > $\mathrm{S_tble}≔\mathrm{table}\left(\left['\mathrm{λ}'=0,'\mathrm{κ}'=0,'\mathrm{σ}'=0,'\mathrm{ρ}'=0,'\mathrm{τ}'=0,'\mathrm{ε}'=0,'\mathrm{α}'=0,'\mathrm{β}'=0,'\mathrm{γ}'=0,'\mathrm{ν}'=0,'\mathrm{μ}'=0,'\mathrm{π}'=0\right]\right)$
 ${\mathrm{S_tble}}{:=}{\mathrm{table}}\left(\left[{\mathrm{τ}}{=}{0}{,}{\mathrm{κ}}{=}{0}{,}{\mathrm{ε}}{=}{0}{,}{\mathrm{ρ}}{=}{0}{,}{\mathrm{β}}{=}{0}{,}{\mathrm{α}}{=}{0}{,}{\mathrm{σ}}{=}{0}{,}{\mathrm{ν}}{=}{0}{,}{\mathrm{γ}}{=}{0}{,}{\mathrm{π}}{=}{0}{,}{\mathrm{λ}}{=}{0}{,}{\mathrm{μ}}{=}{0}\right]\right)$ (9)
 > $\mathrm{compare}\left(\mathrm{S_tble},U\right)$
 ${\mathrm{S_tble is a spin coefficient table; whereas U is a tensor_type.}}$ (10)
 > $\mathrm{compare}\left(\mathrm{S_tble},\mathrm{S_tble}\right)$
 ${\mathrm{Identical}}$ (11)
 > $\mathrm{S2_tble}≔\mathrm{table}\left(\left['\mathrm{λ}'=1,'\mathrm{κ}'=1,'\mathrm{σ}'=1,'\mathrm{ρ}'=1,'\mathrm{τ}'=0,'\mathrm{ε}'=0,'\mathrm{α}'=0,'\mathrm{β}'=0,'\mathrm{γ}'=0,'\mathrm{ν}'=0,'\mathrm{μ}'=0,'\mathrm{π}'=0\right]\right)$
 ${\mathrm{S2_tble}}{:=}{\mathrm{table}}\left(\left[{\mathrm{τ}}{=}{0}{,}{\mathrm{κ}}{=}{1}{,}{\mathrm{ε}}{=}{0}{,}{\mathrm{ρ}}{=}{1}{,}{\mathrm{β}}{=}{0}{,}{\mathrm{α}}{=}{0}{,}{\mathrm{σ}}{=}{1}{,}{\mathrm{ν}}{=}{0}{,}{\mathrm{γ}}{=}{0}{,}{\mathrm{π}}{=}{0}{,}{\mathrm{λ}}{=}{1}{,}{\mathrm{μ}}{=}{0}\right]\right)$ (12)
 > $\mathrm{compare}\left(\mathrm{S_tble},\mathrm{S2_tble}\right)$
 ${\mathrm{κ}}{,}{\mathrm{ρ}}{,}{\mathrm{σ}}{,}{\mathrm{λ}}$ (13)
 > $\mathrm{PHI}≔\mathrm{array}\left(0..2,0..2\right):$
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{from}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}0\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}2\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{for}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}j\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{from}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}0\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}2\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{PHI}}_{i,j}≔1\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end do}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end do}:$$\mathrm{PSI}≔\mathrm{array}\left(0..4,\left[0,1,2,3,4\right]\right):$$\mathrm{C_tble}≔\mathrm{table}\left(\left['\mathrm{Φ}'=\mathrm{op}\left(\mathrm{PHI}\right),'\mathrm{Ψ}'=\mathrm{op}\left(\mathrm{PSI}\right),'R'=r\right]\right)$
 ${\mathrm{C_tble}}{:=}{\mathrm{table}}\left(\left[{R}{=}{r}{,}{\mathrm{Ψ}}{=}{\mathrm{ARRAY}}{}\left(\left[{0}{..}{4}\right]{,}\left[{0}{=}{0}{,}{1}{=}{1}{,}{2}{=}{2}{,}{3}{=}{3}{,}{4}{=}{4}\right]\right){,}{\mathrm{Φ}}{=}{\mathrm{ARRAY}}{}\left(\left[{0}{..}{2}{,}{0}{..}{2}\right]{,}\left[\left({0}{,}{0}\right){=}{1}{,}\left({0}{,}{1}\right){=}{1}{,}\left({0}{,}{2}\right){=}{1}{,}\left({1}{,}{0}\right){=}{1}{,}\left({1}{,}{1}\right){=}{1}{,}\left({1}{,}{2}\right){=}{1}{,}\left({2}{,}{0}\right){=}{1}{,}\left({2}{,}{1}\right){=}{1}{,}\left({2}{,}{2}\right){=}{1}\right]\right)\right]\right)$ (14)
 > $\mathrm{C2_tble}≔\mathrm{table}\left(\left['\mathrm{Φ}'=\mathrm{op}\left(\mathrm{PHI}\right),'\mathrm{Ψ}'=\mathrm{op}\left(\mathrm{PSI}\right),'R'=2r\right]\right)$
 ${\mathrm{C2_tble}}{:=}{\mathrm{table}}\left(\left[{R}{=}{2}{}{r}{,}{\mathrm{Ψ}}{=}{\mathrm{ARRAY}}{}\left(\left[{0}{..}{4}\right]{,}\left[{0}{=}{0}{,}{1}{=}{1}{,}{2}{=}{2}{,}{3}{=}{3}{,}{4}{=}{4}\right]\right){,}{\mathrm{Φ}}{=}{\mathrm{ARRAY}}{}\left(\left[{0}{..}{2}{,}{0}{..}{2}\right]{,}\left[\left({0}{,}{0}\right){=}{1}{,}\left({0}{,}{1}\right){=}{1}{,}\left({0}{,}{2}\right){=}{1}{,}\left({1}{,}{0}\right){=}{1}{,}\left({1}{,}{1}\right){=}{1}{,}\left({1}{,}{2}\right){=}{1}{,}\left({2}{,}{0}\right){=}{1}{,}\left({2}{,}{1}\right){=}{1}{,}\left({2}{,}{2}\right){=}{1}\right]\right)\right]\right)$ (15)
 > $\mathrm{compare}\left(\mathrm{C_tble},\mathrm{C2_tble}\right)$
 ${R}$ (16)
 > $\mathrm{compare}\left(\mathrm{C_tble},\mathrm{C_tble}\right)$
 ${\mathrm{Identical}}$ (17)
 > $\mathrm{compare}\left(\mathrm{C_tble},\mathrm{S_tble}\right)$
 ${\mathrm{C_tble is a curvature component table; whereas S_tble is a spin coefficient table.}}$ (18)