Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1994
*January
*February
*March
*April
*May
*June
*July
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1994

[Date Index] [Thread Index] [Author Index]

Search the Archive

MathLink

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg207] MathLink
  • From: rrigon at zeus.tamu.edu (Riccardo Rigon)
  • Date: Sun, 20 Nov 1994 11:52:24 +0100

Dear mathgrouper, I am moving my first steps into MathLink.
Suppose I would calculate the covariance of two list with an external program:

The following is the code I wrote:

-------covariance.tm------------------------------------------
double mlvariance P(( ml_doublep,ml_doublep, long)); <---THIS SHOULD BE WRONG

:Begin:
:Function:      mlcovariance
:Pattern:       MLCovariance[ list:{___Real},list:{___Real} ]
:Arguments:     { Reverse[list], Reverse[list] }
:ArgumentTypes: { RealList,RealList }
:ReturnType:    Real
:End:

:Evaluate:      MLCovariance[ sequence___Real,sequence___Real]:=
MLCovariance[{sequence},{sequence} ]



------covariance.c--------------------------------------------

#include "mathlink.h"

double mlvariance(list1,list2, len)
        ml_doublep list1,list2; long len;
{
        double res = 0, ras=0, rus=0;
        long lin=len;
        while(len--) {res += list1[len];ras +=list2[len];
rus+=list1[len]*list2[len];}

        return rus/(lin-1)-(res/(lin-1))*(ras/lin);
}

double main(argc, argv)
        int argc; char* argv[];
{
        return MLMain(argc, argv);
}

----------------------------------------------------------


I did not have find any reference to the first line of the template (.tm)
file. Looking at the mathlink.h file I can see that P(s) is substituted at
compiling time with s, but still I do not have clear what is the use of
this first line and how I have to set it. Can anyone help?

I think that the problem of passing and receiving matrixes and lists of
real numbers to and from external programs is an issue of quite general
interest and WRI should deserve to it the time to write some clear
examples. The Mathlink
Reference Guide in my own view is still too much criptic on the subject.

My best regards

Riccardo Rigon, Ph. D.

Civil Egineering Department
Texas A&M University
College Station, TX 77843
ph:  (409)-845-0335
fax: (409)-862-1542
e-mail: rrigon at zeus.tamu.edu







  • Prev by Date: Re: Crandal's notebooks?
  • Next by Date: [no subject]
  • Previous by thread: Re: Crandal's notebooks?
  • Next by thread: Re: MathLink