``````

In [1]:

import numpy as np
from salib import extend

``````

``````

In [9]:

def __init__(self,fx=0.,fy=0.,mz=0.):
if np.isscalar(fx):
self.forces = np.matrix([fx,fy,mz],dtype=np.float64).T
else:
self.forces= fx.copy()

def __mul__(self,scale):
if scale == 1.0:
return self
return self.__class__(self.forces*scale)

__rmul__ = __mul__

def __repr__(self):
return "{}({},{},{})".format(self.__class__.__name__,*list(np.array(self.forces.T)[0]))

def __getitem__(self,ix):
return self.forces[ix,0]

``````
``````

In [10]:

##test:
p, p*2, 3*p

``````
``````

Out[10]:

``````
``````

In [11]:

G = data.get

``````
``````

In [12]:

##test:

``````
``````

Out[12]:

``````

Indices

Implement ...

``````

In [13]:

``````
``````

Out[13]:

43547720

``````
``````

In [14]:

##test:
p[0],p[2]

``````
``````

Out[14]:

(1.0, 3.0)

``````
``````

In [15]:

##test:
fx,fy,mz = p
mz

``````
``````

Out[15]:

3.0

``````
``````

In [16]:

##test:
p[[2,1,0]]

``````
``````

Out[16]:

matrix([[ 3.],
[ 2.],
[ 1.]])

``````

Properties

Implement properties so that ...

``````

In [17]:

@extend

@property
def fx(self):
return self.forces[0,0]

@fx.setter
def fx(self,v):
self.forces[0,0] = v

@property
def fy(self):
return self.forces[1,0]

@fy.setter
def fy(self,v):
self.forces[1,0] = v

@property
def mz(self):
return self.forces[2,0]

@mz.setter
def mz(self,v):
self.forces[2,0] = v

``````
``````

In [18]:

##test:
p.fx, p.fy, p.mz

``````
``````

Out[18]:

(1.0, 2.0, 3.0)

``````
``````

In [19]:

##test:
p.fx = 2
p.fy *= 3
p.mz -= 4
p

``````
``````

Out[19]:

``````
``````

In [ ]:

``````