示例#1
0
int tst3(int n)
   {int ok;
    PM_matrix *a, *b, *val;

    printf("Test #3\n");

    a = test_matrix(n);
    b = PM_create(a->nrow, a->ncol);
    PM_copy(b, a);

/* find eigenvalues and eigenvectors */
    val = PM_eigensys(a);

    printf("Eigenvalues for A:\n");
    PM_print(val);

    printf("Eigenvectors for A:\n");
    PM_print(a);

/* verify */
    ok = check_matrix(a, b, val);

    PM_destroy(val);
    PM_destroy(a);
    PM_destroy(b);

    return(ok);}
示例#2
0
static int oper_test(void)
   {int nrow, ncol;
    PM_matrix *m, *t, *b, *a, *c;

    nrow = 5;
    ncol = 3;

    m = PM_create(nrow, ncol);
    CFREE(m->array);
    m->array = (double *) a1;

    b = PM_create(nrow, 1);
    CFREE(b->array);
    b->array = (double *) b1;
        
    PRINT(STDOUT, "\nMatrix M\n");
    PM_print(m);

    PRINT(STDOUT, "\nMatrix B\n");
    PM_print(b);

    PRINT(STDOUT, "\nMatrix tr(M)\n");
    PM_print(t = PM_transpose(m));

    PRINT(STDOUT, "\nA = tr(M).M (piecewise)\n");
    PM_print(a = PM_times(t, m));
    PM_destroy(t);

    PRINT(STDOUT, "\nT = tr(M).M (nested)\n");
    PM_print(c = PM_times(t = PM_transpose(m), m));
    PM_destroy(c);

    PRINT(STDOUT, "\nC = tr(M).B\n");
    PM_print(c = PM_times(t, b));
    PM_destroy(t);

    PRINT(STDOUT, "\nSolve A.X = C\n");
    PM_print(PM_solve(a, c));
    PM_destroy(a);
    PM_destroy(c);

    PRINT(STDOUT, "\nTest LU decomposition\n");
    a = PM_create(3, 3);
    CFREE(a->array);
    a->array = (double *) tstd;

    PRINT(STDOUT, "\nMatrix A\n");
    PM_print(a);
    PRINT(STDOUT, "\nc = (A)^-1\n");
    PM_print(c = PM_inverse(a));
    PRINT(STDOUT, "\nc.A\n");
    PM_print(t = PM_times(c, a));
    PM_destroy(t);
    PM_destroy(c);

    CFREE(a);
    CFREE(b);
    CFREE(m);

    return(TRUE);}
示例#3
0
JNIEXPORT void JNICALL Java_ConfigManager_destroy(JNIEnv *env, jobject obj)
{
    ParameterManager* pm = GetJavaPMPointer(env, obj);
    if (pm != NULL)
    {
        PM_destroy(pm);
        SetJavaPMPointer(env, obj, NULL);
    }
}
示例#4
0
int main() {
	ParameterManager * params = PM_create(4);
	PM_manage(params,"studentname",STRING_TYPE,1);
    PM_manage(params,"id",INT_TYPE,1);
    PM_manage(params,"regstat",BOOLEAN_TYPE,1);
    PM_manage(params,"marks",LIST_TYPE,1);
    PM_manage(params,"average",REAL_TYPE,0);
	printf("Success?: %d\n", PM_destroy(params));
}
示例#5
0
int tst1(int n)
   {int rv;
    PM_matrix *a, *x;

    printf("Test #1\n");

    rv = TRUE;

    a = test_matrix(n);

/* find the eigenvalues */
    x = PM_eigenvalue(a);

    printf("Eigenvalues for A:\n");
    PM_print(x);

    PM_destroy(x);
    PM_destroy(a);

    return(rv);}
示例#6
0
int PM_eigenvectors(PM_matrix *a)
   {int rv;
    PM_matrix *r;

    rv = FALSE;

    if (a != NULL)
       {if (a->nrow == a->ncol)
	   {r = _PM_hrsymatr(a, TRUE);
    	    rv = _PM_ql_tri_eigen(r, a, TRUE);

	    PM_destroy(r);};};

    return(rv);}
示例#7
0
PM_matrix *PM_eigensys(PM_matrix *a)
   {int i, n, rv;
    PM_matrix *r, *x;

    x = NULL;

    if (a != NULL)
       {if (a->nrow == a->ncol)
	   {n = a->nrow;

	    r  = _PM_hrsymatr(a, TRUE);
    	    rv = _PM_ql_tri_eigen(r, a, TRUE);

	    if (rv == TRUE)
	       {x = PM_create(n, 1);
		for (i = 1; i <= n; i++)
		    PM_element(x, i, 1) = PM_element(r, i, 1);};

	    PM_destroy(r);};};

    return(x);}
示例#8
0
static int det_test(void)
   {int i, n, rv;
    double det;
    PM_matrix *m;

    n = 3;
    m = PM_create(n, n);
    n = n*n;

    for (i = 0; i < n; i++)
        m->array[i] = 0.0;
    PM_element(m, 1, 1) = 1.0;
    PM_element(m, 2, 3) = 1.0;
    PM_element(m, 3, 2) = 1.0;

    det = PM_determinant(m);

    PM_destroy(m);

    rv = (det == -1.0);

    return(rv);}
示例#9
0
int tst2(int n)
   {int rv;
    PM_matrix *a, *b;

    printf("Test #2\n");

    a = test_matrix(n);
    b = PM_create(a->nrow, a->ncol);
    PM_copy(b, a);

/* find the right eigenvectors */
    rv = PM_eigenvectors(a);

    if (rv == TRUE)
       {printf("Eigenvectors for A:\n");
	PM_print(a);};

/* verify */
    rv &= check_matrix(a, b, NULL);

    PM_destroy(a);

    return(rv);}