SignalProcessing
Insert
insert 1-D rtable into another 1-D rtable
Calling Sequence
Parameters
Description
Examples
Compatibility
Insert( A, k, B, options )
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.
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=numelems⁡A, n=numelems⁡B, and A has dimensions α..β. The result of Insert⁡A,k,B contains m+n elements, with B inserted to the left of element Ak. When A is an Array with initial index different than 1, the insertion index k must satisfy α≤k and k≤β+1. When A is a Vector or an Array with initial index 1, on the other hand, the insertion index must satisfy k≠0 and k≤m+1, with k<0 corresponding to element m+1−k.
The extreme case k=α corresponds to inserting B before A, and k=β+1 corresponds to inserting B after A.
Internally, A and B will both be converted to float[8] Vectors, if possible. If this is not possible, they will both be converted to complex[8] 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[8] or complex[8]).
Suppose inplace=true. The container A must have either float[8] or complex[8] 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.
with⁡SignalProcessing:
Example 1
A≔Vectorrow⁡1,2,3,4,5
A≔12345
B≔Vectorrow⁡6,7
B≔67
U≔Insert⁡A,1,B
U≔6.7.1.2.3.4.5.
V≔Insert⁡A,4,B
V≔1.2.3.6.7.4.5.
W≔Insert⁡A,6,B
W≔1.2.3.4.5.6.7.
Example 2
P≔Vectorcolumn⁡0.803716108032327,−0.356056399933928,0.933528218742667,0.0114341122580131,0.554152583724131,datatype=float8
P≔0.803716108032327−0.3560563999339280.9335282187426670.01143411225801310.554152583724131
Q≔Vectorrow⁡−0.0882886912893828,0.561179894580472,0.588474727401137,0.926146043843513,0.821206761885317,datatype=float8
Q≔−0.08828869128938280.5611798945804720.5884747274011370.9261460438435130.821206761885317
Insert⁡P,2,Q,inplace:
P=P
P=0.803716108032327−0.08828869128938280.5611798945804720.5884747274011370.9261460438435130.821206761885317−0.3560563999339280.9335282187426670.01143411225801310.554152583724131
Example 3
G≔1,2−3⁢I,5+6⁢I
H≔4
Insert⁡G,3,H
1.+0.⁢I2.−3.⁢I4.+0.⁢I5.+6.⁢I
Example 4
n≔210:
X≔GenerateSignal⁡sin⁡4⁢t+5,t=0..2⁢π,n,includefinishtime=false:
Y≔GenerateSignal⁡110⁢sin⁡40⁢t+5,t=0..2⁢π,n,includefinishtime=false:
Z≔Insert⁡X,floor⁡n2+1,Y:
SignalPlot⁡Z,view=DEFAULT,0..10,color=blue
Example 5
m≔105
m≔100000
n≔floor⁡23⁢m
n≔66666
A≔LinearAlgebra:-RandomVector⁡m,generator=−5.0..5.0,datatype=complex8
B≔LinearAlgebra:-RandomVector⁡n,generator=−5.0..5.0,datatype=complex8
CodeTools:-Usage⁡Insert⁡A,floor⁡n2,B
memory used=2.57MiB, alloc change=2.55MiB, cpu time=2.00ms, real time=2.00ms, gc time=0ns
The SignalProcessing[Insert] command was introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
See Also
ArrayTools[Copy]
ArrayTools[Extend]
ArrayTools[Insert]
Download Help Document