Esempio n. 1
0
void MDiag (int rank, double ap[], double eigenvalues[], double eigenvectors[])
{
    int info;
    double *work, *rwork;
    work  = Vmem(4*rank);
    rwork = Vmem(3*rank);
    info = 0;
    FORTRAN_SYMBOL(zhpev) ("V", "U", &rank, ap, eigenvalues, eigenvectors,
                           &rank, work, rwork, &info);
    if ( info > 0 )
    {
	printf ("error: MDiag: rank %d matrix failed to converge.\n",
		rank);
	exit(1);
    }
    Vfree (rwork);
    Vfree (work);
} /* end MDiag() */
Esempio n. 2
0
////////////////////////////////////////////////////////////////////////
// FUNCTION:    CategoryCreateList
//
// DESCRIPTION: This routine read a database's categories and store them
//				in a list.
//
// PARAMETERS:  (DmOpenRef) db - Opened database containing category info.
//				(ListType *) listP - A pointer to the list of category
//								names.
//				(UInt16) currentCategory - Category to select
//				(Boolean) showAll - true to have an "ALL" categories
//				(Boolean) showUneditables - true to show uneditable
//								categories.
//				(UInt8) numUneditableCategories - This is the number of
//								categories, starting with the first one
//								at zero.
//				(UInt32) editingStrID - The resource ID os a string to
//								use with the "Edit Categories" list item.
//				(Boolean) resizeList - true to resize the list to the
//								number of categories. Set to true for 
//								pop-ups, false otherwise
//	
// RETURNED:    Nothing
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	3/13/01		Initial Revision
////////////////////////////////////////////////////////////////////////
void CategoryCreateList (DmOpenRef db, ListType *listP, UInt16 currentCategory,
						 Boolean showAll, Boolean showUneditables, 
						 UInt8 numUneditableCategories,
						 UInt32 editingStrID, Boolean resizeList)
{
	UInt16	index=0, k, offset=0;
	Char		word[16];

	if ( !VGetCategoryName (db, 0, word) ) {
		for ( ; index < listP->numItems; index++ ) {
			VWriteCategory ( db, index, listP->itemsText[index], Vstrlen(listP->itemsText[index]) ) ;
		}
	} else {
		// release old listP text memory
		for ( k = 0; k < listP->numItems; k++ ) {
			if ( listP->itemsText[k]);
				Vfree (listP->itemsText[k]);
		}
		if ( listP->itemsText )
			Vfree (listP->itemsText);
		listP->itemsText = NULL;

		// if showAll, add the "ALL" item to the list
		listP->itemsText = (Char **) Vrealloc (listP->itemsText,
								(sizeof(Char *)*(listP->numItems+1)));
		if (showAll) {
			listP->itemsText[index] = (Char*) Vmalloc (4);
			Vstrcpy (listP->itemsText[index++], "All");
			offset = 1;
		}

		do {
			listP->itemsText[index] = (Char*) Vmalloc (Vstrlen(word)+1);
			Vstrcpy (listP->itemsText[index++], word);
		} while ( VGetCategoryName (db, (UInt16)(index-offset), word) );
		listP->numItems = index;
		if ( resizeList ) {
			listP->bounds.extent.y = listP->numItems*FntLineHeight();
		}
	}
}
Esempio n. 3
0
/*
 * configure keyboard definition (DN_KEYDEF)
 */
LOCAL ER setKeyDef( KeyDef *keydef, UW kbsel, UW kid, W datacnt )
{
	ER		err;

	if ( datacnt >= offsetof(KeyDef, keytab.kctmax)
	  && keydef->keytab.keymax == 0 ) {
                /* deletion */
		KbDef	*kbdef = GetKbDef(kbsel, kid);
		if ( kbdef != NULL ) {
			SetKbDef(kbsel, kid, NULL);
			Vfree(kbdef);
		}
	} else {
                /* set */
		if ( (datacnt -= offsetof(KeyDef, keytab)) < 0 )
					return E_PAR;
		err = defineKeyboard(kbsel, kid,
				keydef->keytopofs, &keydef->keytab, datacnt);
		if ( err < E_OK ) return err;
	}

	return E_OK;
}
Esempio n. 4
0
/* B := inv(A), both A and B are real matrices of rank x rank */
void Minv (int rank, double A[], double B[])
{
    int info, *ipiv;
    double *a, *work;
    a = Mmem(rank*rank);
    work = Vmem(rank);
    ipiv = VImem(rank);
    memcpy (a, A, (long)rank*rank*sizeof(double));
    FORTRAN_SYMBOL(dgetrf) (&rank, &rank, a, &rank, ipiv, &info);
    if ( info != 0 )
    {
	printf ("error: Minv: matrix of rank %d is singular.\n",
		rank);
	mump(rank,A);
	exit(1);
    }
    FORTRAN_SYMBOL(dgetri) (&rank, a, &rank, ipiv, work, &rank, &info);
    memcpy (B, a, (long)rank*rank*sizeof(double));
    VFREE (ipiv);
    Vfree (work);
    Mfree (a);
    return;
} /* end Minv() */
Esempio n. 5
0
EXPORT void free( void *ptr )
{
	Vfree(ptr);
}