#include <mpl.h>
#define PRECISION float

/***************************************************************************
*                                                                          *
*   DATA PARALLEL BLAS based on MPL                                        *
*                                                                          *
*   Internal routine, this routine is not supposed to be                   *
*                     called by user programs.                             *
*                                                                          *
*   Version 1.0   1/4-92 ,                                                 *
*   For MasPar MP-1 computers                                              *
*                                                                          *
*   para//ab, University of Bergen, NORWAY                                 *
*                                                                          *
*   The calling sequence may be changed in a future version.               *
*   Please report any BUGs, ideas for improvement or other                 *
*   comments to                                                            *
*                    adm@parallab.uib.no                                   *
*                                                                          *
*   Future versions may then reflect your suggestions.                     *
*   The most current version of this software is available                 *
*   from netlib@nac.no , send the message `send index from maspar'         *
*                                                                          *
*   REVISIONS:                                                             *
*                                                                          *
***************************************************************************/

#ifdef __STDMPL__
void mpl_sq_spsW(
	plural PRECISION a_in,
	plural PRECISION *aps,
	int m,
	int n
	)
#else
void mpl_sq_spsW(a_in,aps,m,n)
	plural PRECISION a_in,*aps;
	int m,n;
#endif


	/* preskewing west on a square machine */

{
	register plural int ix=ixproc,iy=iyproc;
	register int nx=nxproc;
	register plural PRECISION a=a_in;

	/* set elements outside m*n block to zero */

	if ((m<nx) || (n<nx)){
		if ((iy>=m) || (ix>=n)) 
			a = 0.0;
	}
			
	/* use the router to preskew A west */
	/* shift row i by i places */

	*aps = router[iy*nx + ((ix+iy)&(nx-1))].a;
}


/***************************************************************************
*                                                                          *
*   DATA PARALLEL BLAS based on MPL                                        *
*                                                                          *
*   Internal routine, this routine is not supposed to be                   *
*                     called by user programs.                             *
*                                                                          *
*   Version 1.0   1/4-92 ,                                                 *
*   For MasPar MP-1 computers                                              *
*                                                                          *
*   para//ab, University of Bergen, NORWAY                                 *
*                                                                          *
*   The calling sequence may be changed in a future version.               *
*   Please report any BUGs, ideas for improvement or other                 *
*   comments to                                                            *
*                    adm@parallab.uib.no                                   *
*                                                                          *
*   Future versions may then reflect your suggestions.                     *
*   The most current version of this software is available                 *
*   from netlib@nac.no , send the message `send index from maspar'         *
*                                                                          *
*   REVISIONS:                                                             *
*                                                                          *
***************************************************************************/
#ifdef __STDMPL__
void mpl_sq_spsN(
	plural PRECISION a_in,
	plural PRECISION *aps,
	int m,
	int n
	)
#else
void mpl_sq_spsN(a_in,aps,m,n)
	plural PRECISION a_in,*aps;
	int m,n;
#endif

	/* preskewing north on a square machine */

{
	register plural int ix=ixproc,iy=iyproc;
	register int nx=nxproc;
	register plural PRECISION a=a_in;

	/* set elements outside m*n block to zero */

	if ((m<nx) || (n<nx)){
		if ((iy>=m) || (ix>=n)) 
			a = 0.0;
	}
			
	/* use the router to preskew A north */
	/* shift column i by i places */

	*aps = router[((iy+ix)&(nx-1))*nx + ix].a;
}

