Codegen question of qr function

2 次查看(过去 30 天)
alex
alex 2013-1-28
Hi
I am trying to convert QR decomposition (qr) function to convert in c using codegen but it producing the wrong code .
I am using this command line
codegen -args {coder.typeof(double(0), [1 Inf])} -report -config:lib qr -O disable:inline
% code
static void eml_qr(const emxArray_real_T *A, real_T Q_data[1], int32_T Q_size[2],emxArray_real_T *R, emxArray_real_T *E)
that produce the qr function with all arguments are dynamic array but second parameter Q_data is static array ?

回答(2 个)

Ryan Livingston
Ryan Livingston 2013-1-28
Given an m-by-n array A, QR produces a Q which is m-by-m. In this case the declaration:
coder.typeof(double(0), [1 Inf])
says that A is 1-by-? (i.e. a row vector with an unknown number of elements). Therefore, it can be determined that Q is a scalar without need for dynamic sizing.
I would also point out that the generated function "eml_qr" is created from an internal function called by the implementation of QR. In my opinion, it would be advisable to interface with the function:
qr(const emxArray_real_T *A, double Q_data[1], int Q_size[2], emxArray_real_T *R, emxArray_real_T *E);
in case the internal implementation of QR changes.

alex
alex 2013-1-29
Thank you Ryan for the hint.
Finally i managed to get c code working using this command-line
codegen -args {coder.typeof(double(0), [Inf Inf])} -report -config:lib qr -O disable:inline

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by