File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -4148,6 +4148,37 @@ cdef class FreeModuleElement(Vector): # abstract base class
4148
4148
4149
4149
nintegrate=nintegral
4150
4150
4151
+ def concatenate(self, other):
4152
+ r"""
4153
+ Return the result of concatenating this vector with another
4154
+ vector over the same ring.
4155
+
4156
+ EXAMPLES::
4157
+
4158
+ sage: v = vector([1 , 2 , 3 ])
4159
+ sage: w = vector([4 , 5 ])
4160
+ sage: v.concatenate(w)
4161
+ (1 , 2 , 3 , 4 , 5 )
4162
+ sage: v.parent()
4163
+ Ambient free module of rank 3 over the principal ideal domain Integer Ring
4164
+ sage: w.parent()
4165
+ Ambient free module of rank 2 over the principal ideal domain Integer Ring
4166
+ sage: v.concatenate(w).parent()
4167
+ Ambient free module of rank 5 over the principal ideal domain Integer Ring
4168
+
4169
+ The method fails when the vectors aren' t defined over the same ring::
4170
+
4171
+ sage: w2 = vector(QQ, [4 , 5 ])
4172
+ sage: v.concatenate(w2)
4173
+ Traceback (most recent call last):
4174
+ ...
4175
+ ValueError : can only concatenate vectors over the same base ring
4176
+ """
4177
+ R = self.parent().base_ring()
4178
+ if other.parent().base_ring() != R:
4179
+ raise ValueError('can only concatenate vectors over the same base ring')
4180
+ return vector(R, list(self) + list(other))
4181
+
4151
4182
#############################################
4152
4183
# Generic dense element
4153
4184
#############################################
You can’t perform that action at this time.
0 commit comments