| 6595 | |
| 6596 | def test_vecobject(self): |
| 6597 | class Vec: |
| 6598 | def __init__(self, sequence=None): |
| 6599 | if sequence is None: |
| 6600 | sequence = [] |
| 6601 | self.array = np.array(sequence) |
| 6602 | |
| 6603 | def __add__(self, other): |
| 6604 | out = Vec() |
| 6605 | out.array = self.array + other.array |
| 6606 | return out |
| 6607 | |
| 6608 | def __sub__(self, other): |
| 6609 | out = Vec() |
| 6610 | out.array = self.array - other.array |
| 6611 | return out |
| 6612 | |
| 6613 | def __mul__(self, other): # with scalar |
| 6614 | out = Vec(self.array.copy()) |
| 6615 | out.array *= other |
| 6616 | return out |
| 6617 | |
| 6618 | def __rmul__(self, other): |
| 6619 | return self*other |
| 6620 | |
| 6621 | U_non_cont = np.transpose([[1., 1.], [1., 2.]]) |
| 6622 | U_cont = np.ascontiguousarray(U_non_cont) |
no outgoing calls