halcon学习 tuple之算术运算3

//计算数组的自然对数
void TupleLog()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i *10+2;
    }

    HTuple result = tuple1.TupleLog();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算数组以10为底的对数
void TupleLog10()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] =( i+10)* 10;
    }

    HTuple result = tuple1.TupleLog10();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//求两个数组对应位置的最大值
void testTupleMax2()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = 10-i ;
    }
    HTuple tuple2;
    for (int i = 0; i < 10; i++)
    {
        tuple2[i] = i;
    }
    HTuple result = tuple1.TupleMax2(tuple2);
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//求两个数组对应位置的最大值
void testTupleMin2()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = 10 - i;
    }
    HTuple tuple2;
    for (int i = 0; i < 10; i++)
    {
        tuple2[i] = i;
    }
    HTuple result = tuple1.TupleMin2(tuple2);
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算两个整数的相除的余数
void testTupleMod()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i + 15;
    }
    HTuple tuple2;
    for (int i = 0; i < 10; i++)
    {
        tuple2[i] = i + 1;;
    }

    HTuple result = tuple1.TupleMod(tuple2);
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算两个数的相乘
void testTupleMult()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i + 2;
    }
    HTuple tuple2;
    for (int i = 0; i < 10; i++)
    {
        tuple2[i] = i + 1;;
    }

    HTuple result = tuple1.TupleMult(tuple2);
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}


//计算数组的相反数
void testTupleNeg()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i + 2;
    }

    HTuple result = tuple1.TupleNeg();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算两个数组对应的幂
void testTuplePow()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i;
    }
    HTuple tuple2;
    for (int i = 0; i < 10; i++)
    {
        tuple2[i] = i;;
    }

    HTuple result = tuple1.TuplePow(tuple2);
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//转化一个数组的值从角度到弧度
void testTupleRad()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i*36;
    }

    HTuple result = tuple1.TupleRad();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算一个数组中元素的符号{-1,0,1}
void testTupleSgn()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        if (i != 0)
            tuple1[i] = tuple1[i - 1] * (-1);
        else
            tuple1[i] = 1;
    }

    HTuple result = tuple1.TupleSgn();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算数组sin的值
void testTupleSin()
{
    HTuple tuple;
    for (int i = 0; i < 10; i++)
    {
        tuple[i] = (double)(i + 10) / (10.0);
    }
    for (int i = 0; i < 10; i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;
    HTuple result = tuple.TupleSin();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算数组的双曲余弦
//双曲余弦: (e^x-e^-x)/2
void testTupleSinh()
{
    HTuple tuple;
    for (int i = 0; i < 10; i++)
    {
        tuple[i] = (double)(i + 10) / (10.0);
    }
    for (int i = 0; i < 10; i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;
    HTuple result = tuple.TupleSinh();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}


//计算数组的平方根
void testTupleSqrt()
{
    HTuple tuple;
    for (int i = 0; i < 10; i++)
    {
        tuple[i] = i *10;
    }
    for (int i = 0; i < 10; i++)
    {
        cout << (Hlong)tuple[i] << " ";
    }
    cout << endl;
    HTuple result = tuple.TupleSqrt();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//两个数组相减
void testTupleSub()
{
    HTuple tuple1;
    for (int i = 0; i < 10; i++)
    {
        tuple1[i] = i + 8;
    }
    HTuple tuple2;
    for (int i = 0; i < 10; i++)
    {
        tuple2[i] = i + 5;
    }

    HTuple result = tuple1.TupleSub(tuple2);
    for (int i = 0; i < 10; i++)
    {
        cout << (Hlong)result[i] << " ";
    }
}

//计算数组tan的值
void testTupleTan()
{
    HTuple tuple;
    for (int i = 0; i < 10; i++)
    {
        tuple[i] = (double)(i + 10) / (10.0);
    }
    for (int i = 0; i < 10; i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;
    HTuple result = tuple.TupleTan();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

//计算数组的双曲正切
//双曲正切:(e^x+e^-x)/ (e^x-e^-x)
void testTupleTanh()
{
    HTuple tuple;
    for (int i = 0; i < 10; i++)
    {
        tuple[i] = (double)(i + 10) / (10.0);
    }
    for (int i = 0; i < 10; i++)
    {
        cout << (double)tuple[i] << " ";
    }
    cout << endl;
    HTuple result = tuple.TupleTanh();
    for (int i = 0; i < 10; i++)
    {
        cout << (double)result[i] << " ";
    }
}

你可能感兴趣的:(Tuple,算术运算,halcon)