小编use*_*521的帖子

使用SSE加速计算 - 存储,加载和对齐

在我的项目中,我实现了基本的类CVector.该类包含指向原始浮点数组的float*指针.使用标准malloc()函数动态分配此数组.

现在我必须使用这样的向量加速一些计算.不幸的是,因为内存没有使用_mm_malloc()进行分配,所以它没有对齐.

据我所知,我有两个选择:

1)重写代码,分配内存以使用_mm_malloc(),例如使用如下代码:

void sub(float* v1, float* v2, float* v3, int size) 
{  
    __m128* p_v1 = (__m128*)v1;  
    __m128* p_v2 = (__m128*)v2;  
    __m128 res;

    for(int i = 0; i < size/4; ++i)  
    {  
        res = _mm_sub_ps(*p_v1,*p_v2);  
        _mm_store_ps(v3,res);  
        ++p_v1;  
        ++p_v2;  
        v3 += 4;  
    }
}
Run Code Online (Sandbox Code Playgroud)

2)第二个选项是使用_mm_loadu_ps()指令从未对齐的内存加载__m128,然后将其用于计算.

void sub(float* v1, float* v2, float* v3, int size)
{  
    __m128 p_v1;  
    __m128 p_v2;  
    __m128 res;

    for(int i = 0; i < size/4; ++i)  
    {  
        p_v1 = _mm_loadu_ps(v1);   
        p_v2 = _mm_loadu_ps(v2);  
        res = _mm_sub_ps(p_v1,p_v2);    
        _mm_store_ps(v3,res); …
Run Code Online (Sandbox Code Playgroud)

c++ sse

8
推荐指数
1
解决办法
6795
查看次数

wpf toolkit折线图,没有点和不同的线条颜色

我有一些图表,我想动态添加没有DataPoints的LineSeries,只是添加一些自定义颜色的行.我发现隐藏数据点的唯一方法是:

Style style = new Style(typeof(LineDataPoint));
style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, null));

var series = new LineSeries()
{
      Title = name,
      DependentValuePath = "Y",
      IndependentValuePath = "X",
      ItemsSource = new ObservableCollection<FloatingPoint>(),
      DataPointStyle = style,

        };
Run Code Online (Sandbox Code Playgroud)

不幸的是,当我这样做时,所有线条变黄,我无法改变颜色.我试着这样做:

Style style = new Style(typeof(LineDataPoint));
        style.Setters.Add(new Setter(LineDataPoint.TemplateProperty, null));

        SolidColorBrush brush = new SolidColorBrush(Colors.Red);

        var series = new LineSeries()
        {
            Title = name,
            DependentValuePath = "Y",
            IndependentValuePath = "X",
            ItemsSource = new ObservableCollection<FloatingPoint>(),
            DataPointStyle = style,
            Background = brush,

        };
Run Code Online (Sandbox Code Playgroud)

但它没有帮助 - 我无法改变线条颜色......即使我写

series.Background = brush;
Run Code Online (Sandbox Code Playgroud)

c# wpf charts wpftoolkit

8
推荐指数
1
解决办法
1万
查看次数

Heroku没有给出错误的有效,非密码保护的密钥

我有这个文件:

AddTrustExternalCARoot.crt
STAR_mydomain_com.crt
TrustedSecureCertificateAuthority5.crt
USERTrustRSAAddTrustCA.crt
domain.key
Run Code Online (Sandbox Code Playgroud)

domain.key受密码保护,它是在创建CSR文件期间生成的(从证书提供者处获取.crt文件所需的文件.我试过:

heroku certs:update certs/STAR_mydomain_com.crt certs/domain.key
Run Code Online (Sandbox Code Playgroud)

但我得到以下错误:

 !    No valid, non-passphrase-protected keys given.
Run Code Online (Sandbox Code Playgroud)

如何为heroku生成有效的crt/key?(我尝试使用域密钥的所有其他crt文件,但它们不是有效的域证书.


domain.key是使用以下命令生成的:

openssl genrsa -des3 -out domain.key 2048
Run Code Online (Sandbox Code Playgroud)

heroku

8
推荐指数
1
解决办法
2050
查看次数

为什么"docker push"推几张图片又在哪里?

我在docker hub上有私人仓库alek/test.在我的Mac上:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
alek/test           0.1                 dc1a7cc41129        33 minutes ago      643 MB
node                0.12.7              9e20baae42c8        5 days ago          641.6 MB

$ docker push alek/test
The push refers to a repository [docker.io/alek/test] (len: 1)
dc1a7cc41129: Image successfully pushed 
537a913fe639: Image successfully pushed 
b40236e9037f: Image successfully pushed 
53c8b1d50397: Image successfully pushed 
e8c37c1e2189: Image successfully pushed 
68bbfd9543a7: Image successfully pushed 
9e20baae42c8: Image already exists 
8b74d7a75802: Image successfully pushed 
3383909e8f95: Image already exists 
e0919a8b95a8: …
Run Code Online (Sandbox Code Playgroud)

docker dockerhub

8
推荐指数
1
解决办法
3179
查看次数

为什么POST重定向到GET和PUT重定向到PUT?

我使用快递4.13.3(最新)和以下代码:

var express = require('express')

var app = express()

app.get('/test', function (req, res, next) {
  res.send('hello!')
})

app.post('/test', function (req, res, next) {
  res.redirect('/test')
})

app.put('/test', function (req, res, next) {
  res.redirect('/test')
})

app.listen(5001)

// GET /test -> 'hello!'
// POST /test -> 'hello!'
// PUT /test -> ERR_TOO_MANY_REDIRECTS
Run Code Online (Sandbox Code Playgroud)

POST重定向到GET,但PUT重定向到PUT.是否可以使PUT重定向到GET(与POST相同)?

http node.js express

8
推荐指数
2
解决办法
9055
查看次数

dictsort模板过滤和两列过滤

在模板中,我现在使用这个:

{% for item in mydict|dictsortreversed:"column1" %}
Run Code Online (Sandbox Code Playgroud)

但我必须按两列排序数据 - dictsort中有没有选项可以做到这一点?或者在模板中执行此操作的替代方法?

python django django-templates

7
推荐指数
1
解决办法
1893
查看次数

将路线重定向到另一个

我正在尝试在执行路由回调之前将路由重定向到另一个路由.我有以下代码:

console.log("file loaded");
(function (History) {
    var _navigate = History.prototype.navigate;

    _.extend(History.prototype, {
        navigate: function (fragment, opts) {
            alert("adad");
            return _navigate.call(this, fragment, opts);
        }
    });
})(Backbone.History);
Run Code Online (Sandbox Code Playgroud)

此代码包装Backbone.History.navigate方法,并在方法调用上显示警报.但是当我改变路线时,这个警报永远不会出现.

console.log行只是为了确保在backbone.js之后加载了文件.

这段代码有什么问题?

backbone.js backbone-routing

7
推荐指数
1
解决办法
5649
查看次数

如何忽略钩子?

我有以下型号:

sequelize.define("User", {
    id: {
        type: DataTypes.INTEGER(11),
        autoIncrement: true,
        primaryKey: true
    },
    email: {
        type: DataTypes.STRING(255),
        allowNull: false,
        unique: true,
    },
    password: {
        type: DataTypes.STRING(60),
        allowNull: false
    },
    role: {
        type: DataTypes.STRING(32),
        allowNull: false,
        defaultValue: 'user',
    }
},{

    instanceMethods: {
        verifyPassword: function(password,cb) {
            crypt.compare(password,this.password,cb);
        },
    },

    hooks: {
        beforeUpdate: hashPassword,
        beforeCreate: hashPassword,
    }

});
Run Code Online (Sandbox Code Playgroud)

我想像这样创建它,同时忽略 beforeUpdate/Create 钩子:

User.create({ email: 'admin@render.ly', role: 'admin', password: '############' },['email','password','role']).done(function(err,admin){ ... })

如何?

sequelize.js

7
推荐指数
2
解决办法
2274
查看次数

如何在heroku的package.json中引用公共bitbucket repo作为npm模块?

{myrepo}: git://git@bitbucket.org/{myaccount}/{myrepo}.git在packages.json中试过.在我键入的本地机器上sudo npm install(我必须使用sudo)它可以工作,我的repo被克隆到node_modules.

当我将我的应用程序推送到heroku时出现错误:

       npm ERR! git clone git://git@bitbucket.org/{myaccount}/{myrepo}.git Initialized empty Git repository in /app/.npm/_git-remotes/git-git-bitbucket-org-{myaccount}-{myrepo}-git-bd17f867/
       npm ERR! git clone git://git@bitbucket.org/{myaccount}/{myrepo}.git 
       npm ERR! git clone git://git@bitbucket.org/{myaccount}/{myrepo}.git fatal: Unable to look up git@bitbucket.org (Unknown host)
       npm ERR! Error: Command failed: fatal: Unable to look up git@bitbucket.org (Unknown host)
       npm ERR! 
       npm ERR!     at ChildProcess.exithandler (child_process.js:637:15)
       npm ERR!     at ChildProcess.EventEmitter.emit (events.js:98:17)
       npm ERR!     at maybeClose (child_process.js:743:16)
       npm ERR!     at Socket.<anonymous> (child_process.js:956:11)
       npm ERR!     at Socket.EventEmitter.emit (events.js:95:17) …
Run Code Online (Sandbox Code Playgroud)

git heroku bitbucket npm

7
推荐指数
1
解决办法
8649
查看次数

是否有json架构的json架构?

是否有JSON Schema的JSON模式?在我的应用程序中,用户可以上传他的JSON模式,如果它是有效的JSON模式,我想验证它.

json jsonschema

7
推荐指数
1
解决办法
439
查看次数