tensor(deprecated)/compare - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Home : Support : Online Help : tensor(deprecated)/compare

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}{≔}{table}{}\left(\left[{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{compts}}{=}\left[\begin{array}{ccc}{1}& {0}& {0}\\ {0}& {1}& {0}\\ {0}& {0}& {1}\end{array}\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}{≔}{table}{}\left(\left[{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{compts}}{=}\left[\begin{array}{cccc}{1}& {0}& {0}& {0}\\ {0}& {1}& {0}& {0}\\ {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {1}\end{array}\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}{≔}{table}{}\left(\left[{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{compts}}{=}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\end{array}\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}{≔}{table}{}\left(\left[{\mathrm{index_char}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{compts}}{=}\left[\begin{array}{ccc}{x}& {0}& {0}\\ {0}& {y}& {0}\\ {0}& {0}& {z}\end{array}\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{\lambda }'=0,'\mathrm{\kappa }'=0,'\mathrm{\sigma }'=0,'\mathrm{\rho }'=0,'\mathrm{\tau }'=0,'\mathrm{\epsilon }'=0,'\mathrm{\alpha }'=0,'\mathrm{\beta }'=0,'\mathrm{\gamma }'=0,'\mathrm{\nu }'=0,'\mathrm{\mu }'=0,'\mathrm{pi}'=0\right]\right)$
 ${\mathrm{S_tble}}{≔}{table}{}\left(\left[{\mathrm{\gamma }}{=}{0}{,}{\mathrm{\beta }}{=}{0}{,}{\mathrm{\nu }}{=}{0}{,}{\mathrm{\alpha }}{=}{0}{,}{\mathrm{π}}{=}{0}{,}{\mathrm{\kappa }}{=}{0}{,}{\mathrm{\lambda }}{=}{0}{,}{\mathrm{\epsilon }}{=}{0}{,}{\mathrm{\mu }}{=}{0}{,}{\mathrm{\tau }}{=}{0}{,}{\mathrm{\rho }}{=}{0}{,}{\mathrm{\sigma }}{=}{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{\lambda }'=1,'\mathrm{\kappa }'=1,'\mathrm{\sigma }'=1,'\mathrm{\rho }'=1,'\mathrm{\tau }'=0,'\mathrm{\epsilon }'=0,'\mathrm{\alpha }'=0,'\mathrm{\beta }'=0,'\mathrm{\gamma }'=0,'\mathrm{\nu }'=0,'\mathrm{\mu }'=0,'\mathrm{pi}'=0\right]\right)$
 ${\mathrm{S2_tble}}{≔}{table}{}\left(\left[{\mathrm{\gamma }}{=}{0}{,}{\mathrm{\beta }}{=}{0}{,}{\mathrm{\nu }}{=}{0}{,}{\mathrm{\alpha }}{=}{0}{,}{\mathrm{π}}{=}{0}{,}{\mathrm{\kappa }}{=}{1}{,}{\mathrm{\lambda }}{=}{1}{,}{\mathrm{\epsilon }}{=}{0}{,}{\mathrm{\mu }}{=}{0}{,}{\mathrm{\tau }}{=}{0}{,}{\mathrm{\rho }}{=}{1}{,}{\mathrm{\sigma }}{=}{1}\right]\right)$ (12)
 > $\mathrm{compare}\left(\mathrm{S_tble},\mathrm{S2_tble}\right)$
 ${\mathrm{\kappa }}{,}{\mathrm{\lambda }}{,}{\mathrm{\rho }}{,}{\mathrm{\sigma }}$ (13)
 > $\mathrm{PHI}≔\mathrm{array}\left(0..2,0..2\right):$
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{from}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}0\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}2\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}j\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{from}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}0\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}2\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{PHI}\left[i,j\right]≔1\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{PSI}≔\mathrm{array}\left(0..4,\left[0,1,2,3,4\right]\right):$$\mathrm{C_tble}≔\mathrm{table}\left(\left['\mathrm{\Phi }'=\mathrm{op}\left(\mathrm{PHI}\right),'\mathrm{\Psi }'=\mathrm{op}\left(\mathrm{PSI}\right),'R'=r\right]\right)$
 ${\mathrm{C_tble}}{≔}{table}{}\left(\left[{\mathrm{\Psi }}{=}{array}{}\left({0}{..}{4}{,}\left[\left({0}\right){=}{0}{,}\left({1}\right){=}{1}{,}\left({2}\right){=}{2}{,}\left({3}\right){=}{3}{,}\left({4}\right){=}{4}\right]\right){,}{\mathrm{\Phi }}{=}{array}{}\left({0}{..}{2}{,}{0}{..}{2}{,}\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){,}{R}{=}{r}\right]\right)$ (14)
 > $\mathrm{C2_tble}≔\mathrm{table}\left(\left['\mathrm{\Phi }'=\mathrm{op}\left(\mathrm{PHI}\right),'\mathrm{\Psi }'=\mathrm{op}\left(\mathrm{PSI}\right),'R'=2r\right]\right)$
 ${\mathrm{C2_tble}}{≔}{table}{}\left(\left[{\mathrm{\Psi }}{=}{array}{}\left({0}{..}{4}{,}\left[\left({0}\right){=}{0}{,}\left({1}\right){=}{1}{,}\left({2}\right){=}{2}{,}\left({3}\right){=}{3}{,}\left({4}\right){=}{4}\right]\right){,}{\mathrm{\Phi }}{=}{array}{}\left({0}{..}{2}{,}{0}{..}{2}{,}\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){,}{R}{=}{2}{}{r}\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)