%CREF pass data by reference to a C/C++ function in generated code.
%
%   CODER.CEVAL('FCN', CREF(U)...)  passes U by reference to the C
%   function FCN.  Use CREF only within a call to
%   CODER.CEVAL.
%
%   Example:
%     Consider the following C function foo:
%
%     void foo(double* p) {
%       *p = *p + 1;
%     }
%
%     Pass u by reference to foo, use the following source code:
%
%     u = 42.0;
%     coder.ceval('foo', cref(u));
%     % Now u equals 43
%
%   To pass a read-only reference to a C function, set rwflag to 'r'
%
%   Example:
%     Consider the following C function foo:
%
%       double foo(const double* p) {
%         return *p + 1;
%       }
%
%     To invoke foo with a read-only input from the generated code, use the
%     following source code:
%
%       u = 42.0;
%       y = 0.0; % Constrain return type to double
%       y = coder.ceval('foo', cref(u, 'r'));
%       % Now y equals 43
%
%   To pass a write-only reference to a C function, set rwflag to 'w'
%
%   NOTE:
%   - Function FCN should only write to U. It should not read U prior to
%     writing to it because the initial value of U is undefined.
%   - Function FCN must fully initialize U.
%   - If there are prior assignments to U, the compiler might  remove them.
%
%   Example:
%
%   Consider the following C function init:
%
%     void init(double* array, int numel) {
%         for(int i = 0; i < numel; i++) {
%           array[i] = 42;
%         }
%     }
%
%   To invoke init with a write-only input, use the following source code:
%
%     % Constrain output to an int8 matrix.
%     % The following assignment can be removed by the compiler,
%     % because init is expected to fully define y.
%     y = zeros(5, 10, 'double');
%     coder.ceval('init', cref(y, 'w'), numel(y));
%     % Now all elements of y equal 42
%
%   See also coder.ceval
%
%   This is a code generation function. In MATLAB, it generates an error.

 
%   Copyright 2006-2015 The MathWorks, Inc.

