sse2数组添加和初始化 [英] sse2 array addition and initialisation

查看:80
本文介绍了sse2数组添加和初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何声明和初始化输入数组"c"和输出"x"?请参阅下面的代码.

how do i declare and initialise the input array ''c'' and output ''x''? see codes below.

#include "stdafx.h"
#include "emmintrin.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

__m128i *c,*x;

int j;
    for(j = 0;j<4;j++)
    {
        x[j] = _mm_add_epi16(c[j],c[j+3]);
        x[j+1] = _mm_add_epi16(c[j+1],c[j+2]);
        x[j+2] = _mm_sub_epi16(c[j+1],c[j+2]);
        x[j+3] = _mm_sub_epi16(c[j],c[j+3]);
    }
    for (int i = 0; i < 4; i++){
          for (j = 0; j < 4; j++)
             cout << x[i][j] << " ";
          cout << endl;
       }
        return 0;
}

推荐答案

此代码不好-循环4次,因此将x [1]设置为两次,将x [2]设置为三次,等

int * x =来自内存的新int [8].
This code is no good - you loop around 4 times, and thus set x[1] twice, x[2] three times, etc.

int * x = new int[8], from memory.


这篇关于sse2数组添加和初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆