如何初始化const float32x4x4_t(ARM NEON内在,GCC)?

时间:2010-05-01 12:11:50

标签: c gcc struct const neon

我可以像这样初始化float32x4_t:

const float32x4x4_t zero = { 0.0f, 0.0f, 0.0f, 0.0f };

但是此代码在初始化程序

中出现错误不兼容的类型
const float32x4x4_t one =
{
    1.0f, 1.0f, 1.0f, 1.0f,
    1.0f, 1.0f, 1.0f, 1.0f,
    1.0f, 1.0f, 1.0f, 1.0f,
    1.0f, 1.0f, 1.0f, 1.0f,
};

float32x4x4_t是4x4矩阵,构建如下:

typedef struct float32x4x4_t
{
    float32x4_t val[4];
}
float32x4x4_t;

如何初始化此const结构?

1 个答案:

答案 0 :(得分:10)

const float32x4x4_t nameOfVariableHere =
{{
    {1.0f, 1.0f, 1.0f, 1.0f},
    {1.0f, 1.0f, 1.0f, 1.0f},
    {1.0f, 1.0f, 1.0f, 1.0f},
    {1.0f, 1.0f, 1.0f, 1.0f}
}};

第一级括号是结构。
第二级是float32x4_t的数组 第3级是float32x4_t本身。