概述
矢量相反1 (float型矢量相反)
extern void vDSP_vneg(
const float *__A,
vDSP_Stride __IA,
float *__C,
vDSP_Stride __IC,
vDSP_Length __N)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0);
公式:
例子:注:注意例子n*AI不能大于8并且n*cl也不能大于8 (vDSP_zvneg函数出现数组越界)。
float input[8],output[8];
printf("input:n");
for (int i=1; i<=8; i++) {
input[i-1]=-i;
printf("%f ",input[i-1]);
}
vDSP_vneg(input, 1, output, 1, 8);
printf("noutput:n");
for (int i=0; i<8; i++) {
printf("%f ",output[i]);
}
打印结果:
input:
-1.000000 -2.000000 -3.000000 -4.000000 -5.000000 -6.000000 -7.000000 -8.000000
output:
1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000
如改变vDSP_vneg中的函数参数如下:
vDSP_vneg(input, 1, output, 1, 4);
打印结果:
input:
-1.000000 -2.000000 -3.000000 -4.000000 -5.000000 -6.000000 -7.000000 -8.000000
output:
1.000000 2.000000 3.000000 4.000000 0.000000 0.000000 0.000000 0.000000
如改变vDSP_vneg中的函数参数如下:
vDSP_vneg(input, 2, output, 1, 4);
打印结果
input:
-1.000000 -2.000000 -3.000000 -4.000000 -5.000000 -6.000000 -7.000000 -8.000000
output:
1.000000 3.000000 5.000000 7.000000 -0.000000 -0.000000 -0.000000 -0.000000
如改变vDSP_vneg中的函数参数如下:
vDSP_vneg(input, 1, output, 2, 4);
打印结果:
input:
-1.000000 -2.000000 -3.000000 -4.000000 -5.000000 -6.000000 -7.000000 -8.000000
output:
1.000000 0.000000 2.000000 0.000000 3.000000 0.000000 4.000000 0.000000
根据上面的各种情况和公式对比一下,你应该很清楚的明白vDSP_vneg各个参数变化得到结果的变化。
矢量相反2 (double型矢量相反)
extern void vDSP_vnegD(
const double *__A,
vDSP_Stride __IA,
double *__C,
vDSP_Stride __IC,
vDSP_Length __N)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0);
矢量相反3 (float型复数矢量相反)
typedef struct DSPSplitComplex {
float * __nonnull realp;
float * __nonnull imagp;
} DSPSplitComplex;
extern void vDSP_zvneg(
const DSPSplitComplex *__A,
vDSP_Stride __IA,
const DSPSplitComplex *__C,
vDSP_Stride __IC,
vDSP_Length __N)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0);
公式:
例子:
DSPSplitComplex input[8],output[8];
printf("input:n");
for(int i=0;i<8;i++){
float inr[4]={1,2,3,4};
float ini[4]={1,2,3,4};
float outr[4]={0};
float outi[4]={0};
input[i].realp = inr;
input[i].imagp = ini;
output[i].realp = outr;
output[i].imagp = outi;
printf("( ");
for(int j=0;j<4;j++){
printf("%f ",input[i].realp[j]);
}
printf(")+(");
for(int j=0;j<4;j++){
printf("%f ",input[i].imagp[j]);
}
printf(")in");
}
vDSP_zvneg(input,1, output, 1, 4);
printf("noutput:n");
for(int i=0;i<8;i++){
printf("( ");
for(int j=0;j<4;j++){
printf("%f ",output[i].realp[j]);
}
printf(")+( ");
for(int j=0;j<4;j++){
printf("%f ",output[i].imagp[j]);
}
printf(")in");
}
打印结果:
input:
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
output:
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
( -1.000000 -2.000000 -3.000000 -4.000000 )+( -1.000000 -2.000000 -3.000000 -4.000000 )i
如改变vDSP_zvneg中的函数参数如下:
vDSP_zvneg(input,1, output, 1, 2);
打印结果:
input:
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
output:
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
( -1.000000 -2.000000 0.000000 0.000000 )+( -1.000000 -2.000000 0.000000 0.000000 )i
如改变vDSP_zvneg中的函数参数如下:
vDSP_zvneg(input,2, output, 1, 2);
打印结果:
input:( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
output:
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
( -1.000000 -3.000000 0.000000 0.000000 )+( -1.000000 -3.000000 0.000000 0.000000 )i
如改变vDSP_zvneg中的函数参数如下:
vDSP_zvneg(input,1, output, 2, 2);
打印结果:
input:
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
( 1.000000 2.000000 3.000000 4.000000 )+(1.000000 2.000000 3.000000 4.000000 )i
output:
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
( -1.000000 0.000000 -2.000000 0.000000 )+( -1.000000 0.000000 -2.000000 0.000000 )i
根据上面的各种情况和公式对比一下,你应该很清楚的明白vDSP_zvneg各个参数变化得到结果的变化。
注:注意例子n*AI不能大于4并且n*cl也不能大于4 (vDSP_zvneg函数出现数组越界)。
矢量相反4 (double型复数矢量相反)
typedef struct DSPDoubleSplitComplex {
double * __nonnull realp;
double * __nonnull imagp;
} DSPDoubleSplitComplex;
extern void vDSP_zvnegD(
const DSPDoubleSplitComplex *__A,
vDSP_Stride __IA,
const DSPDoubleSplitComplex *__C,
vDSP_Stride __IC,
vDSP_Length __N)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_4_0);
祝你生活愉快!
最后
以上就是无语月饼为你收集整理的iOS vDSP中的单矢量相反的全部内容,希望文章能够帮你解决iOS vDSP中的单矢量相反所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复