Matrix Elements VB-800 Manuel d'utilisateur Page 16

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 172
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 15
8 Appendix A1 Extending Ox
static void OXCALL
fnDecldl(OxVALUE *rtn, OxVALUE *pv, int cArg)
{
int i, j, r; MATRIX md, ml;
OxLibCheckSquareMatrix(pv, 0, 0);
OxLibCheckType(OX_ARRAY, pv, 1, 2);
OxLibCheckArrayMatrix(pv, 1, 2, OxMat(pv, 0));
r = OxMatr(pv, 0);
OxLibValMatDup(OxArray(pv, 1), OxMat(pv, 0), r, r);
OxLibValMatMalloc(OxArray(pv, 2), 1, r);
ml = OxMat( OxArray(pv, 1), 0);
md = OxMat( OxArray(pv, 2), 0);
if (!ml || !md)
OxRunError(ER_OM, NULL);
if (ml == md)
OxRunError(ER_ARGSAME, NULL);
if ( (OxInt(rtn, 0) = !ILDLdec(ml, md[0], r)) == 0)
OxRunMessage("decldl(): decomposition failed");
/* diagonal of ml is 1, upper is 0 */
for (i = 0; i < r; i++)
{ for (j = i + 1; j < r; j++)
ml[i][j] = 0;
ml[i][i] = 1;
}
}
The new functions here are:
OxLibCheckArrayMatrix which checks that the arrays do not point to the ma-
trix to decompose, as in decldl(msym, &msym, &md).
OxLibValMatMalloc allocates space for a matrix.
OxRunError generates a run-time error message. The statement if (ml ==
md) checks if the arrays do not point to the same variable. If so, we have al-
located a matrix twice, but end up with the last matrix for both arguments. This
prevents code of the form decldl(msym, &md, &md).
A1.4 Calling Ox-coded functions from C
This section deals with reverse communication: inside the C (or C
++
) code, we wish
to call an Ox function. The example is a numerical differentiation routine written in C,
used to differentiate a function defined in Ox code.
......................................ox/dev/windows/callback/callback.c (part of)
#include "oxexport.h"
/* ... for FNum1Derivative() see callback.c ... */
Vue de la page 15
1 2 ... 11 12 13 14 15 16 17 18 19 20 21 ... 171 172

Commentaires sur ces manuels

Pas de commentaire