Matlab Codegen Eig函数-这是Bug吗? [英] Matlab Codegen Eig Function - Is this a Bug?

查看:148
本文介绍了Matlab Codegen Eig函数-这是Bug吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下最小示例:

function CoderEigFail() %#codegen
A = [0 sqrt(2); sqrt(2) 0];
[B C] = eig(A)

当我通过codegen CoderEigFail.m编译并运行它时,得到的矩阵B与运行原始Matlab文件时得到的矩阵不同.特别是对于mex文件,我得到B = [1 1; -1 1],而对于Matlab文件,我得到B = [-0.7071 0.7071; 0.7071 0.7071].我在MacOSx Mountain Lion上运行了Matlab R2011a.

When I compile this via codegen CoderEigFail.m and run it, I get a different matrix B than I get when I run the original Matlab file instead. In particular, for the mex file I get B = [1 1; -1 1], while for the Matlab file I get B = [-0.7071 0.7071; 0.7071 0.7071]. I have Matlab R2011a running on MacOSx Mountain Lion.

任何人都可以重现/解释这种行为吗?这是一个错误还是我在这里错过了一些东西?

Can anyone reproduce/explain this behavior? Is this a bug or am I missing something here?

推荐答案

不,这不是bug.

正如Stuart在对该问题的评论中所指出的那样,特征向量通常被归一化. eig() .

As Stuart pointed out in the comment to the question, eigenvectors are generally normalized. This is pointed out in a note in the documentation of eig().

与已编译版本的行为差异是"".

The difference in behavior with the compiled version is a documented feature in "Expected Differences in Behavior After Compiling MATLAB Code" under "For certain advanced library functions".

这种行为只是被承认,但没有理由或解释.

This behavior is simply acknowledged but not justified or explained.

这篇关于Matlab Codegen Eig函数-这是Bug吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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