/*
    DFT++ is a density functional package developed by the research group
    of Professor Tomas Arias

    Copyright 1996-2003 Sohrab Ismail-Beigi

    This file is part of DFT++.

    DFT++ is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    DFT++ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DFT++; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    Please see the file CREDITS for a list of authors.

    For academic users, we request that publications using results obtained with
    this software reference

    "New algebraic formulation of density functional calculation," by Sohrab Ismail-Beigi
    and T.A. Arias, Computer Physics Communications 128:1-2, 1-45 (June 2000).

    and, if using the wavelet basis, further reference

    "Multiresolution analysis of electronic structure: semicardinal and wavelet bases,"
    T.A. Arias, Reviews of Modern Physics 71:1, 267-311 (January 1999).

    and 

    "Robust ab initio calculation of condensed matter: transparent convergence through
    semicardinal multiresolution analysis,'' I.P. Daykov, T.A. Arias, and
    Torkel D. Engeness, Physical Review Letters, 90:21, 216402 (May 2003).

    For your convenience, preprints of the above articles may be obtained from
    http://arXiv.org/abs/cond-mat/9909130, 9805262, and 0204411, respectively.
*/

/* Subroutine */ int convsets3_(double *out, double *outm3, 
	double *outm2, double *outm1, double *outp1, double *
	outp2, double *outp3, int *area, int *stride, int *n, 
                                int *npad, double *tr, double *tf); /* convsets3_ */

/*     Back and forth, linear convolution of sets of points using padding */
/*        for filters of extent +/- 5 (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm5-outp5,out: pointers in in/output array to */
/*         start of data sets */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsets5_(double *out, double *outm5, 
	double *outm4, double *outm3, double *outm2, double *
	outm1, double *outp1, double *outp2, double *outp3, 
	double *outp4, double *outp5, int *area, int *stride, 
                                int *n, int *npad, double *tr, double *tf);/* convsets5_ */

/*     Back and forth, linear convolution of sets of points using padding */
/*        for filters of extent +/- 5 (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm5-outp5,out: pointers in in/output array to */
/*         start of data sets */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsper5_(double *out, double *outm5, 
	double *outm4, double *outm3, double *outm2, double *
	outm1, double *outp1, double *outp2, double *outp3, 
	double *outp4, double *outp5, int *area, int *stride, 
                                   int *n, int *npad, double *tr, double *tf);/* convsetsper5_ */


/*     Back and forth, linear convolution of sets of points using padding */
/*        for filters of extent +/- 5 (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm5-outp5,out: pointers in in/output array to */
/*         start of data sets */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsio5full_(double *datout, double *work, 
	double *workm5, double *workm4, double *workm3, 
	double *workm2, double *workm1, double *workp1, 
	double *workp2, double *workp3, double *workp4, 
	double *workp5, int *area, int *stride, int *n, 
                                      int *npad, int *stridel, double *filter);

/*     Back and forth, linear convolution of sets of points using padding */
/*        for filters of extent +/- 5 (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm5-outp5,out: pointers in in/output array to */
/*         start of data sets */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsiop5full_(double *datout, double *work, 
	double *workm5, double *workm4, double *workm3, 
	double *workm2, double *workm1, double *workp1, 
	double *workp2, double *workp3, double *workp4, 
	double *workp5, int *area, int *stride, int *n, 
                                       int *npad, int *stridel, double *filter);

/*     Back and forth, linear convolution of sets of points using padding */
/*        for filters of extent +/- 5 (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm5-outp5,out: pointers in in/output array to */
/*         start of data sets */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsiopper5_(double *datout, double *work, 
	double *workm5, double *workm4, double *workm3, 
	double *workm2, double *workm1, double *workp1, 
	double *workp2, double *workp3, double *workp4, 
	double *workp5, int *area, int *stride, int *n, 
                                      int *npad, int *stridel, double *tr, double *tf);


/*     Back and forth, linear convolution of sets of points using padding */
/*        for filters of extent +/- 5 (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm5-outp5,out: pointers in in/output array to */
/*         start of data sets */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsioppercum5_(double *datout, double *work,
	 double *workm5, double *workm4, double *workm3, 
	double *workm2, double *workm1, double *workp1, 
	double *workp2, double *workp3, double *workp4, 
	double *workp5, int *area, int *stride, int *n, 
                                         int *npad, int *stridel, double *tr, double *tf);


/*     Back and forth, linear convolution of sets of points using padding, */
/*     computing data ONLY on ghostpoints (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int pconvsets3_(double *out, double *outm3, 
	double *outm2, double *outm1, double *outp1, double *
	outp2, double *outp3, int *area, int *stride, int *n, 
                                 int *npad, double *tr, double *tf);

/*     Back and forth, linear convolution of sets of points using padding */
/*     computing data ONLY on ghostpoints, AND folding in input of a */
/*     different data set (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     in: input/output array for in place computation */
/*     inm3,inm2,inm1,inp1,inp2,inp3: pointers in input array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of out sets */
/*     stride: separation between out data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: separation between in data sets (stride=&in-&inm1) */
/*     fptl, lptl: first and last data components actually present in input */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/*     eflag: mod(,2) of present line (tells if special ghost handling needed) */
/*     zcflag: =1 means we can count on zero ghosts and need special handling */
/* Subroutine */ int pconvsetsi3old_(double *out, double *outm3, 
	double *outm2, double *outm1, double *outp1, double *
	outp2, double *outp3, double *in, double *inm3, 
	double *inm2, double *inm1, double *inp1, double *
	inp2, double *inp3, int *area, int *stride, int *n, 
	int *npad, int *stridel, int *fptl, int *lptl, 
                                     double *tr, double *tf, int *eflag, int *zcflag);




/*     Back and forth, linear convolution of sets of points using padding */
/*     computing data ONLY on ghostpoints, AND folding in input of a */
/*     different data set (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     in: input/output array for in place computation */
/*     inm3,inm2,inm1,inp1,inp2,inp3: pointers in input array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of out sets */
/*     stride: separation between out data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: separation between in data sets (stride=&in-&inm1) */
/*     fptl, lptl: first and last data components actually present in input */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/*     eflag: mod(,2) of present line (tells if special ghost handling needed) */
/*     zcflag: =1 means we can count on zero ghosts and need special handling */
/* Subroutine */ int pconvsetsi3new_(double *out, double *in, 
	double *inm3, double *inm2, double *inm1, double *
	inp1, double *inp2, double *inp3, int *area, int *
	stride, int *n, int *npad, int *stridel, int *fptl, 
                                     int *lptl, double *filt, int *eflag, int *zcflag);

/*     Back and forth, linear convolution of sets of points using padding */
/*     computing data ONLY on ghostpoints, AND folding in input of a */
/*     different data set (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     in: input/output array for in place computation */
/*     inm3,inm2,inm1,inp1,inp2,inp3: pointers in input array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of out sets */
/*     stride: separation between out data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: separation between in data sets (stride=&in-&inm1) */
/*     fptl, lptl: first and last data components actually present in input */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/*     eflag: mod(,2) of present line (tells if special ghost handling needed) */
/*     zcflag: =1 means we can count on zero ghosts and need special handling */
/* Subroutine */ int pconvsetsi8new_(double *out, double *in, 
	double *inm8, double *inm7, double *inm6, double *
	inm5, double *inm4, double *inm3, double *inm2, 
	double *inm1, double *inp1, double *inp2, double *
	inp3, double *inp4, double *inp5, double *inp6, 
	double *inp7, double *inp8, int *area, int *stride, 
	int *n, int *npad, int *stridel, int *fptl, int *
                                     lptl, double *filt, int *eflag, int *zcflag);

/*     Back and forth, linear convolution of sets of points using padding, */
/*     computing data ONLY on ghostpoints (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int pconvsetsio3full_(double *out, double *in, 
	double *inm3, double *inm2, double *inm1, double *
	inp1, double *inp2, double *inp3, int *area, int *
                                       stride, int *n, int *npad, double *filt);


/*     Back and forth, linear convolution of sets of points using padding, */
/*     computing data ONLY on ghostpoints (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int pconvsetsio8full_(double *out, double *in, 
	double *inm8, double *inm7, double *inm6, double *
	inm5, double *inm4, double *inm3, double *inm2, 
	double *inm1, double *inp1, double *inp2, double *
	inp3, double *inp4, double *inp5, double *inp6, 
	double *inp7, double *inp8, int *area, int *stride, 
                                       int *n, int *npad, double *filt);




/*     Back and forth, linear convolution of sets of points for +/- 3 */
/*     onvolutions  using padding, and ignoring input data on non-ghost */
/*     points (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsp3_(double *out, double *in, double *
	inm3, double *inm2, double *inm1, double *inp1, 
	double *inp2, double *inp3, int *area, int *stride, 
                                 int *n, int *npad, double *tr, double *tf);



/*     Back and forth, linear convolution of sets of points for +/- 3 */
/*     onvolutions  using padding, and ignoring input data on non-ghost */
/*     points (IN PLACE) */

/*     out: input/output array for in place computation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers in output array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetsp8full_(double *out, double *in, 
	double *inm8, double *inm7, double *inm6, double *
	inm5, double *inm4, double *inm3, double *inm2, 
	double *inm1, double *inp1, double *inp2, double *
	inp3, double *inp4, double *inp5, double *inp6, 
	double *inp7, double *inp8, int *area, int *stride, 
                                     int *n, int *npad, double *filter);


/*     Back and forth, linear convolution of sets of points for +/- 3 */
/*      filters using padding, ignoring input data on non-ghost points */
/*      (IN/+=OUT) */

/*     lower: output array for accumulation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers to input work array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: stride on output */
/*     fptl,lptl: first,last actual points in output set */
/*     fsetl,lsetl: first,last actual sets in output */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetspop3_(double *lower, double *out, 
	double *outm3, double *outm2, double *outm1, double *
	outp1, double *outp2, double *outp3, int *area, int *
	stride, int *n, int *npad, int *stridel, int *fptl, 
                                   int *lptl, int *fsetl, int *lsetl, double *filt);



/*     Back and forth, linear convolution of sets of points using padding, */
/*     ignoring input data on non-ghost points (IN/OUT) */

/*     lower: output array */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers to input work array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: stride on output */
/*     fptl,lptl: first,last actual points in output set */
/*     fsetl,lsetl: first,last actual sets in output */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetspo3_(double *lower, double *out, 
	double *outm3, double *outm2, double *outm1, double *
	outp1, double *outp2, double *outp3, int *area, int *
	stride, int *n, int *npad, int *stridel, int *fptl, 
	int *lptl, int *fsetl, int *lsetl, double *tr, 
                                  double *tf);

/*     Back and forth, linear convolution of sets of points for +/- 3 */
/*      filters using padding, ignoring input data on non-ghost points */
/*      (IN/+=OUT) */

/*     lower: output array for accumulation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers to input work array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: stride on output */
/*     fptl,lptl: first,last actual points in output set */
/*     fsetl,lsetl: first,last actual sets in output */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetspo8full_(double *lower, double *out, 
	double *outm8, double *outm7, double *outm6, double *
	outm5, double *outm4, double *outm3, double *outm2, 
	double *outm1, double *outp1, double *outp2, double *
	outp3, double *outp4, double *outp5, double *outp6, 
	double *outp7, double *outp8, int *area, int *stride, 
	int *n, int *npad, int *stridel, int *fptl, int *
                                      lptl, int *fsetl, int *lsetl, double *filt);

/*     Back and forth, linear convolution of sets of points for +/- 3 */
/*      filters using padding, ignoring input data on non-ghost points */
/*      (IN/+=OUT) */

/*     lower: output array for accumulation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers to input work array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: stride on output */
/*     fptl,lptl: first,last actual points in output set */
/*     fsetl,lsetl: first,last actual sets in output */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetspom3_(double *lower, double *out, 
	double *outm3, double *outm2, double *outm1, double *
	outp1, double *outp2, double *outp3, int *area, int *
	stride, int *n, int *npad, int *stridel, int *fptl, 
                                   int *lptl, int *fsetl, int *lsetl, double *filt);


/*     lower: output array */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers to input work array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: stride on output */
/*     fptl,lptl: first,last actual points in output set */
/*     fsetl,lsetl: first,last actual sets in output */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetspoadd3_(double *lower, double *addon, 
	double *out, double *outm3, double *outm2, double *
	outm1, double *outp1, double *outp2, double *outp3, 
	int *area, int *stride, int *n, int *npad, int *
	stridel, int *fptl, int *lptl, int *fsetl, int *lsetl,
                                     double *tr, double *tf);



/*     Back and forth, linear convolution of sets of points for +/- 3 */
/*      filters using padding, ignoring input data on non-ghost points */
/*      (IN/+=OUT) */

/*     lower: output array for accumulation */
/*     outm3,outm2,outm1,outp1,outp2,outp3: pointers to input work array to */
/*         start of data sets, 3 previous, 2 previous, 1 previous, 1 forward, */
/*         2 forward, 3 forward */
/*     area: total size of each set */
/*     stride: separation between data sets (stride=&out-&outm1) */
/*     n: actual number of data sets being convolved */
/*     npad: size of padded region needed for "leakage" of foward filters */
/*     stridel: stride on output */
/*     fptl,lptl: first,last actual points in output set */
/*     fsetl,lsetl: first,last actual sets in output */
/*     tr: reverse-time filter coefficients */
/*     tf: forward-time filter coefficients */
/* Subroutine */ int convsetspop8full_(double *lower, double *out, 
	double *outm8, double *outm7, double *outm6, double *
	outm5, double *outm4, double *outm3, double *outm2, 
	double *outm1, double *outp1, double *outp2, double *
	outp3, double *outp4, double *outp5, double *outp6, 
	double *outp7, double *outp8, int *area, int *stride, 
	int *n, int *npad, int *stridel, int *fptl, int *
                                       lptl, int *fsetl, int *lsetl, double *filt);




