1.1Tuple数组的基本操作
*1、Tuple数组元素的创建
*1.1、创建一个空数组
assign([],empty_tuple) //采用赋值操作
empty_tuple:=[] //采用赋值操作
*1.2、创建一个整型数组
assign([1,2,3,4,5,6,7,8,9,10],tupleInt1) //采用赋值操作
tupleInt1 := [1,0,3,4,5,6,7,8,9] //采用赋值操作
tupleInt2 := [] //创建一个空数组
tupleInt2[0]:=100 //对数组成员进行赋值操作
tupleInt2[1]:=200 //对数组成员进行赋值操作
tupleInt2[2]:=300 //对数组成员进行赋值操作
*1.3、以批量赋值的方式创建数组
*创建具有指定长度和相同常量元素的数组
tuple_gen_const (100, 1, tupleInt3) //采用构造函数
tupleInt3:=gen_tuple_const(100, 1) //采用赋值操作
*创建一个指定长度的在区间[0,1)内均匀分布的随机数数组
tuple_rand (100, Rand1)
Rand2:=rand(100) //采用赋值操作
*创建一个等差序列数组
tuple_gen_sequence (1, 100, 1, tupleInt4) //采用构造函数
tupleInt4 := [0:100] //采用赋值操作
tuple_gen_sequence (100, -100, -5, tupleInt5) //采用构造函数
tupleInt5 := [100:-5:-100] //采用赋值操作
*2、Tuple数组元素的插入
tupleInt6 := [0,1,2,3,4,5] //采用赋值操作
*在数组的指定索引处插入一个元素
tuple_insert (tupleInt6, 6, 6, tupleInsert1)
tupleInsert1:=insert(tupleInt6, 6, 'A') //采用赋值操作
*在数组的指定索引处插入多个元素
tuple_insert (tupleInt6, 6, [6,7,8], tupleInsert2)
tupleInsert2:=insert(tupleInt6, 6, [6,7,8]) //采用赋值操作
*3、Tuple数组元素的删除
*在数组的指定索引处删除一个元素
tuple_remove (tupleInsert1, 6, tupleReduced1)
tupleReduced1:=remove(tupleInsert1, 6) //采用赋值操作
*在数组的指定索引处删除多个元素
tuple_remove (tupleInsert2, [6,7,8], tupleReduced2)
tupleReduced2:=remove(tupleInsert2, [6,7,8]) //采用赋值操作
*4、Tuple数组元素的替换
*在数组的指定索引处替换一个元素
tuple_replace (tupleInt6, 0, 100, tupleReplaced1)
tupleReplaced1:=replace(tupleInt6, 0, 100) //采用赋值操作
*在数组的指定索引处替换多个元素
tuple_replace (tupleInt6, [0,1,2], ['x','y','z'], tupleReplaced2)
tupleReplaced2:=replace(tupleInt6, [0,1,2], ['x','y','z']) //采用赋值操作
*5、Tuple数组元素的合并
TupleInt := [1,2,3]
TupleReal := [1.1,2.1,3.1]
TupleChar := ['a','b','c']
*计算两个数组的并集
tuple_union (TupleInt, TupleReal, tupleUnion1)
tupleUnion1:=union(TupleInt, TupleReal) //采用赋值操作
*合并两个数组
tuple_concat (TupleInt, TupleReal, tupleConcat1)
tupleConcat1:=[TupleInt,TupleReal]
*合并多个数组,以数组作为输入
tupleConcat2:=[TupleInt,TupleReal,TupleChar] //采用赋值操作
*合并多个数组,以数组、常量和变量作为输入
tupleConcat3:=[TupleInt,'a',rand(3)] //采用赋值操作
*[[t]]=[t]=t,t可以是变量或数组
a1:=1
a2:=[a1]
a3:=[[a1]]
a4:=[[[a1]]]
a5:=[[[[a1]]]]
b1:=[200,300,400]
b2:=[b1]
b3:=[[b1]]
b4:=[[[b1]]]
b5:=[[[[b1]]]]
*6、Tuple数组元素的查找
tupleInt7:=[1:1:10]
tupleInt8:=[1,2,2,3,4,2,3,4,2,1]
*返回ToFind元组在Tuple元组中出现的索引,索引值从0开始
tuple_find (tupleInt7, [3,4,5], findIndex)
findIndex:=find(tupleInt7, [3,4,5]) //采用赋值操作
*返回ToFind元组在Tuple元组中第一次出现的索引,索引值从0开始。
tuple_find_first (tupleInt8, [2,3,4], findFirstIndex)
findFirstIndex:=find_first(tupleInt8, [2,3,4]) //采用赋值操作
*返回ToFind元组在Tuple元组中最后一次出现的索引,索引值从0开始。
tuple_find_last (tupleInt8, [2,3,4], findLastIndex)
findLastIndex:=find_last(tupleInt8, [2,3,4]) //采用赋值操作
*7、Tuple数组元素的转换
tupleTest:=[1,2.3,3.14,4.5,5.0,6.8]
*将一个数组转换成整型数组(向下取整)
tuple_int (tupleTest, tupleInt)
tupleInt:=int(tupleTest) //采用赋值操作
*将一个数组转换成整型数组(四舍五入)
tuple_round (tupleTest, tupleRound)
tupleRound:=round(tupleTest) //采用赋值操作
*将一个数组转换成浮点数数组
tuple_real (tupleTest, tupleReal)
tupleReal:=real(tupleTest) //采用赋值操作
1.2Tuple数组的选择
tupleTest:=[1:100]
*1、返回数组中的索引为Index的单个或多个元素
tuple_select (tupleTest,0, Selected1)
Selected1 := tupleTest[0]
tuple_select (tupleTest,[1:2:100] , Selected2)
Selected2 := subset(tupleTest, [1:2:100])
*2、返回tuple中索引值为[Leftindex,Rightindex]的连续个元素
tuple_select_range (tupleTest, 9, 18, Selected3)
Selected3:= tupleTest[9:18]
*3、对数组元素进行排序,并返回排序索引为RankIndex的元素
tuple_select_rank (tupleTest, 2, Selected4)
Selected4:=select_rank(tupleTest, 2)
*4、丢弃输入元组tuple中除一个元素外的所有连续相同元素,并返回Uniq中剩余的元素。
tupleRepeat:=[0,0,1,1,1,1,2,0,1]
tuple_uniq (tupleRepeat, Uniq1)
Uniq1:=uniq(tupleRepeat)
Uniq1:=uniq(sort(tupleRepeat))
1.3Tuple数组的特征
tupleTest:=[1,2,3,3,4,5,5,4,3,3,2,1]
*1、求数组中的元素个数
Length:=|tupleTest|
tuple_length (tupleTest, Length)
*2、求数组中的最大元素
MaxElement:=max(tupleTest)
tuple_max (tupleTest, MaxElement)
*3、求数组中的最小元素
MinElement:=min(tupleTest)
tuple_min (tupleTest, MinElement)
*4、求数组元素的中位数
Median:=median(tupleTest)
tuple_median (tupleTest, Median)
*5、求数组元素的平均值
Mean:=mean(tupleTest)
tuple_mean (tupleTest, Mean)
*6、求数组中所有元素的和
Sum:=sum(tupleTest)
tuple_sum (tupleTest, Sum)
*7、求数组元素的标准差
Deviation:=deviation(tupleTest)
tuple_deviation (tupleTest, Deviation)
*8、求数组的值分布
tuple_rand (10, Tuple)
MinValue := 0.0
MaxValue := 1.0
NumBins := 5
tuple_histo_range (Tuple, MinValue, MaxValue, NumBins, Histo, BinSize)
1.4Tuple数组的排序
tupleTest:=[1.2,8.4,6.3,2.5,3.3,5.1,7.9,4.3,9.9]
*1、对元组中的元素按升序排序
Sorted:=sort(tupleTest)
tuple_sort (tupleTest, Sorted)
*2、对输入元组中的元素进行升序排序,并返回相对于输入元组的索引
Indices:=sort_index(tupleTest)
tuple_sort_index (tupleTest, Indices)
*3、求输入元组的逆序(与原来的顺序相反)元组
Inverted:=inverse(tupleTest)
tuple_inverse (tupleTest, Inverted)
1.5Tuple数组的比较
*0、准备元组数据
tupleTest1:=[3]
tupleTest2:=[1,2]
tupleTest3:=[1,2,3]
tupleTest4:=[3,2,1]
tupleTest5:=[1,2,3,4,5]
tupleTest6:=[1,2.0,3.0,4.0,5]
tupleTest7:=[1.0,2.0,3.0,4.0,5.5]
tupleTest8:=[1.1,2.2,3.3,4.4,5.5]
tupleTest9:= [1, 2,'c']
tupleTest10:=['a','b',3]
tupleTest11:=['a','b','c']
tupleTest12:=['a','b','c','d']
*1、两个元组比较(不不含等于)
*1.1、判断一个元组是否大于另一个元组
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*大于(前n(min(|T1|,|T2|)元素分别相等并且T1的长度大于T2)
tuple_greater (tupleTest3, tupleTest2, Greater1) //比较数字元组
tuple_greater (tupleTest12, tupleTest11, Greater2) //比较字符串元组
Greater1:=tupleTest3>tupleTest2
Greater2:=tupleTest12>tupleTest11
*大于(逐元素比较,如果相等,则检查下一对元素。T1中的元素值大于T2中的元素值,终止比较)
tuple_greater (tupleTest1, tupleTest2, Greater3) //比较数字元组
tuple_greater (tupleTest4, tupleTest3, Greater4) //比较字符串元组
*1.2、判断一个元组是否小于另一个元组
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*小于(前n(min(|T1|,|T2|)元素分别相等并且T1的长度小于T2)
tuple_less (tupleTest2, tupleTest3, Less1) //比较数字元组
tuple_less (tupleTest11, tupleTest12, Less2) //比较字符串元组
Less1:=tupleTest2<tupleTest3
Less2:=tupleTest11<tupleTest12
*小于(逐元素比较,T1中的元素值小于T2中的元素值,终止比较)
tuple_less (tupleTest2, tupleTest1, Less3) //比较数字元组
tuple_less (tupleTest3, tupleTest4, Less4) //比较字符串元组
*小于(逐元素比较,如果相等,则检查下一对元素。T1中的元素值小于T2中的元素值,终止比较)
tuple_less (tupleTest5, tupleTest7, Less5) //比较数字元组
*1.3、判度两个元组是否相等(相等:1;不相等:0)
*相等(两个元组的长度相同且元素值分别相等)
tuple_equal (tupleTest5, tupleTest6, Equal1) //比较数字元组(不区分整型和浮点型)
tuple_equal (tupleTest11, tupleTest11, Equal2) //比较字符串元组
Equal1 := tupleTest5 == tupleTest6
Equal2 := tupleTest11 = tupleTest12
*1.4、判断两个元组是否不相等(相等:0;不相等:1)
*不相等(两个元组的长度不同)
tuple_not_equal (tupleTest2,tupleTest4 , Nequal1) //比较数字元组
tuple_not_equal (tupleTest2,tupleTest9 , Nequal2) //比较数字元组和混合元组
tuple_not_equal (tupleTest11,tupleTest12 , Nequal3) //字符串元组
Nequal1:=tupleTest2!=tupleTest4
Nequal2:=tupleTest2#tupleTest9
*不相等(元组长度相同且元素值不分别相等)
tuple_not_equal (tupleTest3, tupleTest4, Nequal4) //比较数字元组
tuple_not_equal (tupleTest6, tupleTest7, Nequal5) //比较数字元组
tuple_not_equal (tupleTest9, tupleTest10, Nequal6) //比较混合(字符串和数字)元组
tuple_not_equal (tupleTest10, tupleTest11, Nequal7) //比较混合元组和字符串元组
*2、两个元组比较(包含等于)
*2.1、判断一个元组是否大于或等于另一个元组
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*大于(前n(min(|T1|,|T2|)元素分别相等并且T1的长度大于T2)
tuple_greater_equal (tupleTest3, tupleTest2, GreaterEq1) //比较数字元组
tuple_greater_equal (tupleTest12, tupleTest11, GreaterEq2) //比较字符串元组
GreaterEq1:=tupleTest3>tupleTest2
GreaterEq2:=tupleTest12>tupleTest11
*大于(逐元素比较,如果相等,则检查下一对元素。T1中的元素值大于T2中的元素值,终止比较)
tuple_greater_equal (tupleTest1, tupleTest2, GreaterEq3) //比较数字元组
tuple_greater_equal (tupleTest4, tupleTest3, GreaterEq4) //比较字符串元组
*相等(两个元组的长度相同且元素值分别相等)
tuple_greater_equal (tupleTest5, tupleTest6, GreaterEq5) //比较数字元组
tuple_greater_equal (tupleTest11, tupleTest11, GreaterEq6) //比较字符串元组
*2.2、测试一个元组是否小于或等于另一个元组。
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*小于(前n(min(|T1|,|T2|)元素分别相等并且T1的长度小于T2)
tuple_less_equal (tupleTest2, tupleTest3, LessEq1) //比较数字元组
tuple_less_equal (tupleTest11, tupleTest12, LessEq2) //比较字符串元组
LessEq1:=tupleTest2<=tupleTest3
LessEq2:=tupleTest11<=tupleTest12
*小于(逐元素比较,T1中的元素值小于T2中的元素值,终止比较)
tuple_less_equal (tupleTest2, tupleTest1, LessEq3) //比较数字元组
tuple_less_equal (tupleTest3, tupleTest4, LessEq4) //比较数字元组
*小于(逐元素比较,如果相等,则检查下一对元素。T1中的元素值小于T2中的元素值,终止比较)
tuple_less_equal (tupleTest5, tupleTest7, LessEq5) //比较数字元组
*相等(两个元组的长度相同且元素值分别相等)
tuple_less_equal (tupleTest5, tupleTest6, LessEq6) //比较数字元组
tuple_less_equal (tupleTest11, tupleTest11, LessEq7) //比较字符串元组
*2.3、判断两个输入元组在元素上是否相等
*两个元组的长度相同,则比较两个元组的对应元素是否相等
tuple_equal_elem (tupleTest5, tupleTest6, EqualEle1) //比较数字元组
tuple_equal_elem (tupleTest6, tupleTest7, EqualEle2) //比较数字元组
tuple_equal_elem (tupleTest10, tupleTest11, EqualEle3) //比较混合元组和字符串元组
EqualEle1:=tupleTest6[==]tupleTest7
EqualEle2:=tupleTest10[=]tupleTest11
*将长元组的每个元素(元组长度大于1)与另一个单元素的元组(元组长度等于1)进行比较(与元组输入顺序无关)
tuple_equal_elem (tupleTest1, tupleTest3, EqualEle4) //比较数字元组
tuple_equal_elem (tupleTest10, tupleTest1, EqualEle5) //比较混合元组和数字元组
*2.4、判断两个输入元组在元素上是否不相等
*两个元组的长度相同,则比较两个元组的对应元素是否不相等
tuple_not_equal_elem (tupleTest5, tupleTest6, NequalEle1) //比较数字元组
tuple_not_equal_elem (tupleTest6, tupleTest7, NequalEle2) //比较数字元组
tuple_not_equal_elem (tupleTest10, tupleTest11, NequalEle3) //比较混合元组和字符串元组
NequalEle1:=tupleTest6[!=]tupleTest7
NequalEle2:=tupleTest10[#]tupleTest11
*将长元组的每个元素(元组长度大于1)与另一个单元素的元组(元组长度等于1)进行比较(与元组输入顺序无关)
tuple_not_equal_elem (tupleTest1, tupleTest3, NequalEle4) //比较数字元组
tuple_not_equal_elem (tupleTest10, tupleTest1, NequalEle5) //比较混合元组和数字元组
*3、两个元组的元素比较
*3.1、判断一个元组在元素上是否大于另一个元组。
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*两个元组的长度相同,则比较两个元组的对应元素
tuple_greater_elem (tupleTest5, tupleTest6, GreaterEle1) //比较数字元组
tuple_greater_elem (tupleTest7, tupleTest6, GreaterEle2) //比较数字元组
tuple_greater_elem (tupleTest11, tupleTest11, GreaterEle3) //比较字符串元组
*将长元组的每个元素(元组长度大于1)与另一个单元素的元组(元组长度等于1)进行比较(与元组输入顺序无关)
tuple_greater_elem (tupleTest1, tupleTest3, GreaterEle4) //比较数字元组
tuple_greater_elem (tupleTest5, tupleTest1, GreaterEle5) //比较数字元组
GreaterEle4:=tupleTest1[>]tupleTest3
GreaterEle5:=tupleTest5[>]tupleTest1
*3.2、判断一个元组在元素上是否大于或等于另一个元组。
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*两个元组的长度相同,则比较两个元组的对应元素
tuple_greater_equal_elem (tupleTest5, tupleTest6, GreaterEqEle1) //比较数字元组
tuple_greater_equal_elem (tupleTest7, tupleTest6, GreaterEqEle2) //比较数字元组
tuple_greater_equal_elem (tupleTest11, tupleTest11, GreaterEqEle3) //比较字符串元组
*将长元组的每个元素(元组长度大于1)与另一个单元素的元组(元组长度等于1)进行比较(与元组输入顺序无关)
tuple_greater_equal_elem (tupleTest1, tupleTest3, GreaterEqEle4) //比较数字元组
tuple_greater_equal_elem (tupleTest5, tupleTest1, GreaterEqEle5) //比较数字元组
GreaterEqEle4:=tupleTest1[>]tupleTest3
GreaterEqEle5:=tupleTest5[>]tupleTest1
*3.3、判断一个元组在元素上是否小于另一个元组
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*两个元组的长度相同,则比较两个元组的对应元素
tuple_less_elem (tupleTest5, tupleTest6, LessEle1) //比较数字元组
tuple_less_elem (tupleTest6, tupleTest7, LessEle2) //比较数字元组
tuple_less_elem (tupleTest11, tupleTest11, LessEle3) //比较字符串元组
*将长元组的每个元素(元组长度大于1)与另一个单元素的元组(元组长度等于1)进行比较(与元组输入顺序无关)
tuple_less_elem (tupleTest1, tupleTest3, LessEle4) //比较数字元组
tuple_less_elem (tupleTest5, tupleTest1, LessEle5) //比较数字元组
LessEle4:=tupleTest1[<]tupleTest3
LessEle5:=tupleTest5[<]tupleTest1
*3.4、判断一个元组在元素上是否小于或等于另一个元组。
*作为按元素比较元组的先决条件,两个对应的元素要么都是(整数或浮点数)数字,要么都是字符串。
*两个元组的长度相同,则比较两个元组的对应元素
tuple_less_equal_elem (tupleTest5, tupleTest6, LessEqEle1) //比较数字元组
tuple_less_equal_elem (tupleTest6, tupleTest7, LessEqEle2) //比较数字元组
tuple_less_equal_elem (tupleTest11, tupleTest11, LessEqEle3) //比较字符串元组
*将长元组的每个元素(元组长度大于1)与另一个单元素的元组(元组长度等于1)进行比较(与元组输入顺序无关)
tuple_less_equal_elem (tupleTest3, tupleTest1, LessEqEle4) //比较数字元组
tuple_less_equal_elem (tupleTest5, tupleTest1, LessEqEle5) //比较数字元组
LessEqEle4:=tupleTest3[<=]tupleTest1
LessEqEle5:=tupleTest5[<=]tupleTest1
*总结:
* 判断两个元组是否相等:两个元组长度不同时,两个元组不相等;两个元组长度相同且对应元素值不同时,两个元组不相等;
* 其他判断:要求两个元组的对应元素要么都是(整数或浮点数)数字,要么都是字符串。
1.6Tuple数组的基本算术运算
tupleInt1:=[1,2,3]
tupleInt2:=[4,5,6]
tupleReal1:=[1.0,2.0,3.0]
tupleReal2:=[4.0,5.0,6.0]
*1、数组的加法运算
SumInt1:=tupleInt1 + tupleInt2
tuple_add (tupleInt1, tupleInt2, SumInt1)
SumReal1:=tupleInt1 + tupleReal1
tuple_add (tupleInt1, tupleReal1, SumReal1)
*2、数组的减法运算
DiffInt1:=tupleInt1 - tupleInt2
tuple_sub (tupleInt1, tupleInt2, DiffInt1)
DiffReal1:=tupleInt1 - tupleReal2
tuple_sub (tupleInt1, tupleReal2, DiffReal1)
*3、数组的乘法运算
MultInt1:=tupleInt1 * tupleInt2
tuple_mult (tupleInt1, tupleInt2, MultInt1)
MultReal1:=tupleInt1 * tupleReal2
tuple_mult (tupleInt1, tupleReal2, MultReal1)
*4、数组的除法运算
DivInt1:=tupleInt2 / tupleInt1
tuple_div (tupleInt2, tupleInt1, DivInt1)
DivReal1:=tupleReal2 / tupleInt1
tuple_div (tupleReal2, tupleInt1, DivReal1)
*5、数组的求余运算
ModInt1:= tupleInt2 % tupleInt1
tuple_mod (tupleInt2, tupleInt1, ModInt1)
*6、数组的取反运算
NegInt1:= - tupleInt1
tuple_neg (tupleInt1, NegInt1)
NegReal1:= - tupleReal1
tuple_neg (tupleReal1, NegReal1)
1.7Tuple数组的其他算术运算
tupleTest1:=[-3.14,-0.38,-0.23,0,1.9,2,3,4.8]
*1、返回输入数组中最大的元素值
tuple_max (tupleTest1, tupleMax1)
tupleMax1:=max(tupleTest1)
*2、返回输入数组中最小的元素值
tuple_min (tupleTest1, tupleMin1)
tupleMin1:=min(tupleTest1)
tupleTest2:=[-3.14,-0.38,-0.23,0,1,2,3]
*3、计算输入数组的绝对值(整数的绝对值仍然是整数;浮点数的绝对值是浮点数)
tuple_abs (tupleTest2, tupleAbs1)
tupleAbs1:=abs(tupleTest1)
*4、以浮点数的形式返回输入数组的绝对值
tuple_fabs (tupleTest2, tupleAbs2)
tupleAbs2:=fabs(tupleTest1)
tupleTest3:=[1,2,3,4,5]
*5、对输入数组中的所有元素求和
tuple_sum (tupleTest3, tupleSum1)
tupleSum1:=sum(tupleTest3)
*6、计算两个元组的幂函数
tuple_pow (tupleTest3, tupleTest3, tuplePow1)
tuple_pow (tupleTest3, 2, tuplePow2)
tuplePow2:=pow(tupleTest3, 2)
*7、计算输入元组的平方根
tuple_sqrt (tupleTest3, tupleSqrt1)
tupleSqrt1:=sqrt(tupleTest3)
tupleTest4:=[-3.99,-3.50,-3.14,-0.99,-0.21,0.0,0.21,0.99,3.14,3.50,3.99]
*8、将元组转换为整数元组(四舍五入)
tuple_round (tupleTest4, tupleRound1)
tupleRound1:=round(tupleTest4)
*9、对输入数组进行向下取整(小于等于T的最大整数,以浮点数形式返回)
tuple_floor (tupleTest4, tupleFloor1)
tupleFloor1:=floor(tupleTest4)
*10、对输入数组进行向上取整(大于等于T的最小整数,以浮点数形式返回)
tuple_ceil (tupleTest4, tupleCeil1)
tupleTest5:=[1,3,2,8,5]
tupleTest6:=[3,1,5,4,2]
*11、返回两个元组对应元素相比较的最大值
tuple_max2 (tupleTest5, tupleTest6, tupleMax21)
tupleMax21:=max2(tupleTest5, tupleTest6)
tuple_max2 (tupleTest5, 3, tupleMax22)
*12、返回两个元组对应元素相比较的最小值
tuple_min2 (tupleTest5, tupleTest6, tupleMin21)
tupleMin21:=min2(tupleTest5,tupleTest6)
*13、将一个元组从角度转换成弧度
tupleTest7:=[0,45,90,135,180,270,360]
tuple_rad (tupleTest7, tupleRad1)
tupleRad1:=rad(tupleTest7)
*14、将一个元组从弧度转换为角度
tupleTest8:=[0.0, 0.785398, 1.5708, 2.35619, 3.14159, 4.71239, 6.28319]
tuple_deg (tupleTest8, tupleDeg1)
tupleDeg1:=deg(tupleTest8)
1.8Tuple数组的位运算
a:=[0x10,0xff]
b:=[0x10,0x00]
*1、计算两个数组的按位与
tuple_band (a, b, tupleBAnd1)
tupleBAnd1:= a band b
*2、计算两个数组的按位或
tuple_bor (a, b, tupleBOr1)
tupleBOr1:= a bor b
*3、对数组元素按位取反
tuple_bnot (a, tupleBNot1)
tupleBNot1:= bnot a
*4、计算两个数组的按位异或
tuple_bxor (a, b, tupleBXor1)
tupleBXor1:= a bxor b
*5、对数组中的元素按位左移
tuple_lsh (a, 2, tupleLsh1)
tupleLsh1:= lsh(a, 2)
*6、对数组中的元素按位右移
tuple_rsh (a, 2, tupleRsh1)
tupleRsh1:=rsh(a, 2)
1.9Tuple数组的逻辑运算
tupleTest1:=[1,0,1,0]
tupleTest2:=[1,1,0,0]
*1、计算两个数组的逻辑与
tuple_and (tupleTest1,tupleTest2 , tupleAnd1)
tupleAnd1:= tupleTest1 and tupleTest2
tuple_and (tupleTest1,[3], tupleAnd2)
tupleAnd2:= tupleTest1 and 3
*2、计算两个数组的逻辑或
tuple_or (tupleTest1,tupleTest2 , tupleOr1)
tupleAnd1:= tupleTest1 or tupleTest2
tuple_or (tupleTest1,[3], tupleOr2)
tupleOr2:= tupleTest1 or 3
*3、计算数组的逻辑非
tuple_not (tupleTest1, tupleNot1)
tupleNot1:= not tupleTest1
tuple_not (0, tupleNot2)
tupleNot2:= not 0
tuple_not (-3, tupleNot3)
tupleNot3:= not -3
*4、计算两个数组的逻辑异或
tuple_xor (tupleTest1,tupleTest2 , tupleXor1)
tupleXor1:= tupleTest1 xor tupleTest2
标签:tupleTest,tupleTest1,tuple,元素,元组,HALCON,数组,数据结构
From: https://blog.csdn.net/qq_44744164/article/details/142862071