/* MJACAN.f -- translated by f2c (version 19960827).
   You must link the resulting object file with the libraries:
	-lf2c -lm   (in that order)
*/

#include "Data_f2c.h"
#include <Data_Data.h>
#ifdef WNT
#include <MathBase.h>
#else 
#define  __MathBase_API
#endif

/* Common Block Declarations */

/*extern __Data_API struct {*/
extern struct {
    doublereal plgcan[3968]	/* was [496][2][4] */, canplg[3968]	/* 
	    was [496][2][4] */;
} mmjcobi_;

#define mmjcobi_1 mmjcobi_

/* Subroutine */ __MathBase_API int mmjacan_(ideriv, ndeg, poljac, polcan)
integer *ideriv, *ndeg;
doublereal *poljac, *polcan;
{
    /* System generated locals */
    integer poljac_dim1, i__1, i__2;

    /* Local variables */
    static integer iptt, i__, j, ibb;
    static doublereal bid;
    extern integer mnfndeb_();
    extern /* Subroutine */ int mgenmsg_(), mgsomsg_();



/* < */
/* **NOTICE */
/*  THIS SOFTWARE IS THE PROPERTY OF CISIGRAPH. */
/*  THIS CODE MUST NOT BE DISTRIBUTED OR COPIED WITHOUT THE PRIOR */
/*  WRITTEN PERMISSION OF CISIGRAPH AND IS ONLY TO BE USED ON THE */
/*  SITE WHERE IT IS INSTALLED BY CISIGRAPH */
/* **NOTICE */

/* ***********************************************************************
 */

/*     FONCTION : */
/*     ---------- */
/*     Routine de transfert de Jacobi normalise a canonique [-1,1], les */
/*     tableaux etant ranges en termes de degre pair puis impair. */

/*     MOTS CLES : */
/*     ----------- */
/*        LEGENDRE,JACOBI,PASSAGE. */

/*     ARGUMENTS D'ENTREE : */
/*     ------------------ */
/*        IDERIV : Ordre de Jacobi compris entre -1 et 2. */
/*        NDEG : Le degre vrai du polynome. */
/*        POLJAC : Le polynome dans la base de Jacobi. */

/*     ARGUMENTS DE SORTIE : */
/*     ------------------- */
/*        POLCAN : La courbe exprimee dans la base canonique [-1,1]. */

/*     COMMONS UTILISES   : */
/*     ---------------- */

/*     REFERENCES APPELEES   : */
/*     ----------------------- */

/*     DESCRIPTION/REMARQUES/LIMITATIONS : */
/*     ----------------------------------- */

/* $    HISTORIQUE DES MODIFICATIONS   : */
/*     -------------------------------- */
/*     04-01-90 : NAK ; COMMON MMJCOBI PAR INCLUDE MMJCOBI */
/*     12-04-1989 : RBD ; Appel MGSOMSG. */
/*     27-04-1988 : JJM ; Test NDEG=0 */
/*     01-03-1988 : JJM ; Creation. */

/* > */
/* ***********************************************************************
 */

/*   Le nom de la routine */

/*   Matrices de conversion */

/*     INCLUDE MMJCOBI */
/* < */
/* **NOTICE */
/*  THIS SOFTWARE IS THE PROPERTY OF CISIGRAPH. */
/*  THIS CODE MUST NOT BE DISTRIBUTED OR COPIED WITHOUT THE PRIOR */
/*  WRITTEN PERMISSION OF CISIGRAPH AND IS ONLY TO BE USED ON THE */
/*  SITE WHERE IT IS INSTALLED BY CISIGRAPH */
/* **NOTICE */

/* ***********************************************************************
 */

/*     FONCTION : */
/*     ---------- */
/*        MATRICE DE TRANSFORMATION DS LA BASE DE LEGENDRE */

/*     MOTS CLES : */
/*     ----------- */
/*        MATH */

/*     DEMSCRIPTION/REMARQUES/LIMITATIONS : */
/*     ----------------------------------- */

/* $    HISTORIQUE DES MODIFICATIONS : */
/*     ------------------------------ */
/*     04-01-90 : NAK ; Creation version originale */
/* > */
/* ***********************************************************************
 */



/*  Common de Legendre/Casteljau comprime. */

/*   0:1 0 Concerne les termes pairs, 1 les termes impairs. */
/*   CANPLG : Matrice de passage de canonique vers Jacobi avec parites */
/*            comptees */
/*   PLGCAN : Matrice de passage de Jacobi vers canonique avec parites */
/*            comptees. */




/* ***********************************************************************
 */

    /* Parameter adjustments */
    poljac_dim1 = *ndeg / 2 + 1;

    /* Function Body */
    ibb = mnfndeb_();
    if (ibb >= 5) {
	mgenmsg_("MMJACAN", 7L);
    }

/* ----------------- Expression des termes de degre pair ---------------- 
*/

    i__1 = *ndeg / 2;
    for (i__ = 0; i__ <= i__1; ++i__) {
	bid = 0.;
	iptt = i__ * 31 - (i__ + 1) * i__ / 2 + 1;
	i__2 = *ndeg / 2;
	for (j = i__; j <= i__2; ++j) {
	    bid += mmjcobi_1.plgcan[iptt + j + *ideriv * 992 + 991] * poljac[
		    j];
/* L310: */
	}
	polcan[i__ * 2] = bid;
/* L300: */
    }

/* --------------- Expression des termes de degre impair ---------------- 
*/

    if (*ndeg == 0) {
	goto L9999;
    }

    i__1 = (*ndeg - 1) / 2;
    for (i__ = 0; i__ <= i__1; ++i__) {
	bid = 0.;
	iptt = i__ * 31 - (i__ + 1) * i__ / 2 + 1;
	i__2 = (*ndeg - 1) / 2;
	for (j = i__; j <= i__2; ++j) {
	    bid += mmjcobi_1.plgcan[iptt + j + ((*ideriv << 1) + 1) * 496 + 
		    991] * poljac[j + poljac_dim1];
/* L410: */
	}
	polcan[(i__ << 1) + 1] = bid;
/* L400: */
    }

/* -------------------------------- The end ----------------------------- 
*/

L9999:
    if (ibb >= 5) {
	mgsomsg_("MMJACAN", 7L);
    }
    return 0;
} /* mmjacan_ */

