|
An
Entire Atom Vector (AV) may be extracted, by
subscripting, and the Extract AV that results can
be treated like any other AV with regards to
operators, methods and functions.
Only
an Entire and mapped AV can be subscripted. The key
must be an AtomGroup
object and the key and the Entire AV must share the
same atom map. Thus:
X
= N[m]
X
is a new Extract AV formed from the Entire AV
N
from the key m
where N
and m
share an Atom Map.
>>> print `Top` /5:a1:b1/3:a2:b2/4:a3/2:a4:b4\b3:c3:d3/5:c4:d4/0\e4:f4:g4\\c2\c1:d1/2:d2:e2\e1/2:f2/2:e3:f3\g2/0\\\ >>> print `Gd3` /5:c4:d4/0\e4:f4:g4\ >>> from Yup.Taro.AtomVect import * >>> A = AtomVector( Top ) >>> B = A[Gd3] >>> print A.numatom, A.numdimen, A.firstatom, A.lastatom, A.type 16 3 0 15 Entire-Mapped >>> print B.numatom, B.numdimen, B.firstatom, B.lastatom, B.type 4 3 6 9 Extract-Mapped >>>
|
In
the above example, Top
is the root node of an Atom Map and
Gd3
is a descendent node. A
is an AV mapped to Top
and B
is an extract of A
formed by subscripting
A
with the Gd3
node as key. The vital statistics are printed in
the last two commands.
You
can assign to a subscripted AV. The source must be
conformal with the subscripted AV. For
example:
>>> A AtomVector[16:3] { 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }
>>> A[Gd3] = AtomVector( numatom=Gd3.numatoms, sample='UNIFORM' ) >>> A AtomVector[16:3] { 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.131382 0.0241401 -0.213294 0.16831 0.739189 0.488083 0.928526 -0.954222 0.770989 0.243873 -0.293435 0.299112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }
>>>
|
This
works with inplace operators as well.
Note
that the following:
B =
A[Gd3]
B = AtomVector( numatom=Gd3.numatoms,
sample='UNIFORM' )
would
not have the outcome that some may expect. In the
first line, the Gd3
slice of A
forms a new Extract AV which is assigned to the
variable B.
In the second line, this reference is removed and
B
is pointed to a new Entire AV.
A
does not receive any new values.
The
len()
function returns the length of the vector in the AV
which is the product of the number of atoms and the
number of dimensions.
An
extract can also be formed using the
Extract()
function, see the Functions
page. An Anonymous Atom Vector cannot be
subscripted to form an extract but any Entire Atom
Vector can be sliced using the
Extract()
function.
|