 Insert - Maple Help

SignalProcessing

 Insert
 insert 1-D rtable into another 1-D rtable Calling Sequence Insert( A, k, B, options ) Parameters

 A, B - 1-D rtables or lists with entries of type complexcons k - integer; specifies the index of A where B is to be inserted inplace - (optional) Either true or false, specifies if the insertion of B into A at k is to be performed in-place. Description

 • The Insert command inserts 1-D rtable or list B into 1-D rtable or list A at index k, and returns the combined container.
 • When A is an rtable, the rtable order and subtype of the output are the same as for A. When A is a list, on the other hand, the output is an Array having Fortran order.
 • Any passed rtables must have no indexing function, and use rectangular storage.
 • Suppose $m=\mathrm{numelems}\left(A\right)$, $n=\mathrm{numelems}\left(B\right)$, and $A$ has dimensions $\mathrm{\alpha }..\mathrm{\beta }$. The result of $\mathrm{Insert}\left(A,k,B\right)$ contains $m+n$ elements, with $B$ inserted to the left of element ${A}_{k}$. When $A$ is an Array with initial index different than $1$, the insertion index $k$ must satisfy $\mathrm{\alpha }\le k$ and $k\le \mathrm{\beta }+1$. When $A$ is a Vector or an Array with initial index $1$, on the other hand, the insertion index must satisfy $k\ne 0$ and $\left|k\right|\le m+1$, with $k<0$ corresponding to element $m+1-k$.
 • The extreme case $k=\mathrm{\alpha }$ corresponds to inserting $B$ before $A$, and $k=\mathrm{\beta }+1$ corresponds to inserting $B$ after $A$.
 • Internally, A and B will both be converted to float Vectors, if possible. If this is not possible, they will both be converted to complex Vectors, if possible. For this reason, it is more efficient for the passed containers A and B to both be 1-D rtables of the same double precision hardware float datatype (float or complex).
 • Suppose inplace=true. The container A must have either float or complex datatype, and the container B must be coercible to the same datatype. Moreover, if B is an alias of A, or A and B are both aliases of the same rtable, then a copy of B is created in order to avoid complications during insertion.
 • The Insert command is not thread safe. Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$ Example 1

 > $A≔{\mathrm{Vector}}_{'\mathrm{row}'}\left(\left[1,2,3,4,5\right]\right)$
 ${A}{≔}\left[\begin{array}{ccccc}{1}& {2}& {3}& {4}& {5}\end{array}\right]$ (1)
 > $B≔{\mathrm{Vector}}_{'\mathrm{row}'}\left(\left[6,7\right]\right)$
 ${B}{≔}\left[\begin{array}{cc}{6}& {7}\end{array}\right]$ (2)
 > $U≔\mathrm{Insert}\left(A,1,B\right)$
 ${U}{≔}\left[\begin{array}{ccccccc}{6.}& {7.}& {1.}& {2.}& {3.}& {4.}& {5.}\end{array}\right]$ (3)
 > $V≔\mathrm{Insert}\left(A,4,B\right)$
 ${V}{≔}\left[\begin{array}{ccccccc}{1.}& {2.}& {3.}& {6.}& {7.}& {4.}& {5.}\end{array}\right]$ (4)
 > $W≔\mathrm{Insert}\left(A,6,B\right)$
 ${W}{≔}\left[\begin{array}{ccccccc}{1.}& {2.}& {3.}& {4.}& {5.}& {6.}& {7.}\end{array}\right]$ (5) Example 2

 > $P≔{\mathrm{Vector}}_{'\mathrm{column}'}\left(\left[0.803716108032327,-0.356056399933928,0.933528218742667,0.0114341122580131,0.554152583724131\right],'\mathrm{datatype}'='{\mathrm{float}}_{8}'\right)$
 ${P}{≔}\left[\begin{array}{c}{0.803716108032327}\\ {-0.356056399933928}\\ {0.933528218742667}\\ {0.0114341122580131}\\ {0.554152583724131}\end{array}\right]$ (6)
 > $Q≔{\mathrm{Vector}}_{'\mathrm{row}'}\left(\left[-0.0882886912893828,0.561179894580472,0.588474727401137,0.926146043843513,0.821206761885317\right],'\mathrm{datatype}'='{\mathrm{float}}_{8}'\right)$
 ${Q}{≔}\left[\begin{array}{ccccc}{-0.0882886912893828}& {0.561179894580472}& {0.588474727401137}& {0.926146043843513}& {0.821206761885317}\end{array}\right]$ (7)
 > $\mathrm{Insert}\left(P,2,Q,'\mathrm{inplace}'\right):$
 > $'P'=P$
 ${P}{=}\left[\begin{array}{c}{0.803716108032327}\\ {-0.0882886912893828}\\ {0.561179894580472}\\ {0.588474727401137}\\ {0.926146043843513}\\ {0.821206761885317}\\ {-0.356056399933928}\\ {0.933528218742667}\\ {0.0114341122580131}\\ {0.554152583724131}\end{array}\right]$ (8) Example 3

 > $G≔\left[1,2-3I,5+6I\right]$
 ${G}{≔}\left[{1}{,}{2}{-}{3}{}{I}{,}{5}{+}{6}{}{I}\right]$ (9)
 > $H≔\left[4\right]$
 ${H}{≔}\left[{4}\right]$ (10)
 > $\mathrm{Insert}\left(G,3,H\right)$
 $\left[\begin{array}{c}{1.}{+}{0.}{}{I}\\ {2.}{-}{3.}{}{I}\\ {4.}{+}{0.}{}{I}\\ {5.}{+}{6.}{}{I}\end{array}\right]$ (11) Example 4

 > $n≔{2}^{10}$
 ${n}{≔}{1024}$ (12)
 > $X≔\mathrm{GenerateSignal}\left(\mathrm{sin}\left(4t\right)+5,t=0..2\mathrm{Pi},n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $Y≔\mathrm{GenerateSignal}\left(\frac{1\mathrm{sin}\left(40t\right)}{10}+5,t=0..2\mathrm{Pi},n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $Z≔\mathrm{Insert}\left(X,\mathrm{floor}\left(\frac{n}{2}\right)+1,Y\right):$
 > $\mathrm{SignalPlot}\left(Z,'\mathrm{view}'=\left['\mathrm{DEFAULT}',0..10\right],'\mathrm{color}'='\mathrm{blue}'\right)$  Example 5

 > $m≔{10}^{5}$
 ${m}{≔}{100000}$ (13)
 > $n≔\mathrm{floor}\left(\frac{2m}{3}\right)$
 ${n}{≔}{66666}$ (14)
 > $A≔\mathrm{LinearAlgebra}:-\mathrm{RandomVector}\left(m,'\mathrm{generator}'=-5.0..5.0,'\mathrm{datatype}'='{\mathrm{complex}}_{8}'\right)$ > $B≔\mathrm{LinearAlgebra}:-\mathrm{RandomVector}\left(n,'\mathrm{generator}'=-5.0..5.0,'\mathrm{datatype}'='{\mathrm{complex}}_{8}'\right)$ > $\mathrm{CodeTools}:-\mathrm{Usage}\left(\mathrm{Insert}\left(A,\mathrm{floor}\left(\frac{n}{2}\right),B\right)\right)$
 memory used=2.57MiB, alloc change=2.55MiB, cpu time=2.00ms, real time=2.00ms, gc time=0ns  Compatibility

 • The SignalProcessing[Insert] command was introduced in Maple 2022.