Help with this Paradiso Example Please

Help with this Paradiso Example Please

Hi Guys,
I am new with the IMKL 8.0 library using MS Visual C++ Version 7.1
I am able tu run the Paradiso Example Sparse Direct.cpp

Then I proceeded to modify the program to read in a matrix and perform a similar calculation. The matrix is a 10 by 10 that looks like this:
12368463120
2100000000
3010000000
6001000000
8000100000
4000010000
6000001000
3000000100
1000000010
20000000001

The B vector looks like this:
1
2
0
0
3
6
5
1
1
6

I am trying to learn how to use this but (under the example program everything works) when I modified to read this matrix in I get an error when performing

error = dss_factor_real( handle, type, values );

The message that I get is: The program '[788] Paradiso Example Sparse Direct.exe: Native' has exited with code -1 (0xffffffff)

Any ideas, the code is set here below:

Thanks in advance..
Marcias Martinez

// Paradiso Example Sparse Direct.cpp : Defines the entry point for the console application.

//

/*

*******************************************************************************

* Copyright(C) 2001-2004 Intel Corporation. All Rights Reserved.

* The source code contained or described herein and all documents related to

* the source code ("Material") are owned by Intel Corporation or its suppliers

* or licensors. Title to the Material remains with Intel Corporation or its

* suppliers and licensors. The Material contains trade secrets and proprietary

* and confidential information of Intel or its suppliers and licensors. The

* Material is protected by worldwide copyright and trade secret laws and

* treaty provisions. No part of the Material may be used, copied, reproduced,

* modified, published, uploaded, posted, transmitted, distributed or disclosed

* in any way without Intel's prior express written permission.

* No license under any patent, copyright, trade secret or other intellectual

* property right is granted to or conferred upon you by disclosure or delivery

* of the Materials, either expressly, by implication, inducement, estoppel or

* otherwise. Any license under such intellectual property rights must be

* express and approved by Intel in writing.

*

*******************************************************************************

*

* Content : Intel MKL DSS C example

*

*******************************************************************************

*/

#include "stdafx.h"

#define<
FONT color=#000000> NROWS 5

#define NROWSV 10

#define NCOLS 5

#define NCOLS_V 10

#define NNONZEROS 9

#define NNONZEROS_V 19

#define NRHS 1

#define TESTINT 1

static const int nRows = NROWS ;

static const int nRows_V = NROWSV ;

static const int nCols = NCOLS ;

static const int nCols_V = NCOLS_V ;

static const int nNonZeros = NNONZEROS ;

static const int nNonZeros_V = NNONZEROS_V ;

static const int nRhs = NRHS ;

static _INTEGER_t rowIndex[NROWS+1]; //= { 1, 6, 7, 8, 9, 10 };

static _INTEGER_t rowIndex_V[11]; //= { 1, 6, 7, 8, 9, 10 };

static const int perm[11];

static _INTEGER_t columns[NNONZEROS];// = { 1, 2, 3, 4, 5, 2, 3, 4, 5 };

static _INTEGER_t co
lumns_V[nNonZeros_V];

static _DOUBLE_PRECISION_t values[NNONZEROS]; // = { 9, 1.5, 6, .75, 3, 0.5, 12, .625, 16 };

static _DOUBLE_PRECISION_t values_v[nNonZeros_V];

static _DOUBLE_PRECISION_t rhs[NCOLS]; //= { 1, 2, 3, 4, 5 };

static _DOUBLE_PRECISION_t rhs_V[NCOLS_V];

double GSM[10][10];

//static _DOUBLE_PRECISION_t test[TESTINT];

void main() {

int i, j, k,l;

/* Allocate storage for the solver handle and the right-hand side. */

_DOUBLE_PRECISION_t solValues[NROWSV];

_MKL_DSS_HANDLE_t handle;

_INTEGER_t error;

_CHARACTER_STR_t statIn[] = "determinant";

_DOUBLE_PRECISION_t statOut[5];

//int opt =MKL_DSS_MY_ORDER;

int opt = MKL_DSS_DEFAULTS;

int sym = MKL_DSS_SYMMETRIC;

int type = MKL_DSS_POSITIVE_DEFINITE;

int stop;

/* Read data in from File */

// The next step is to be able to store this in dynamic arrays that I can insert

// into the solver.

// Input of the K-Matrix Square and the B Vector

std::ifstream inB;

inB.open("b_vector2.txt"); //open file for input

if (!inB){

std::cout<< " Connot open file
";

// handle error

std::cin >> stop;

exit(0);

} // End if

for(i=0; i

inB >> rhs_V[i];

} // End for Topology i

inB.close();

std::ifstream inK;

inK.open("K-Matrix_Square2.txt"); //open file for input

if (!inK){

std::cout<< " Connot open file
";

// handle error

std::cin >> stop;

exit(0);

} // End if

for(i=0; i

for(j=0; j

inK >> GSM[i][j];

} // end for j

} // End for Topology i

inK.close();

// Here we loop through the GSM matrix to determine how many non zeroswe have.

k=0;

// To determine the size of the array.

for(i=0; i<10; i++){

for(j=i; j<10; j++){

//rhs_V[j]=0;

if(GSM[i][j] != 0.0){

k++;

} // end if

} // end for j

} // End for Topology i

k=0;

l=1;

int p, nonzerovalues_in_row;

p =-1;

nonzerovalues_in_row =0;

rowIndex_V[0]=1;

for(i=0; i<10; i++){

for(j=i; j<10; j++){

if(GSM[i][j] != 0.0){

values_v[k]=GSM[i][j];

columns_V[k]=j+1;

k++;

nonzerovalues_in_row++;

} // end for j

} // End for Topology j

p++;

rowIndex_V[p+1]= rowIndex_V[p]+nonzerovalues_in_row;

nonzerovalues_in_row =0;

} // End for Topology i

/*

std::ifstream indata;

indata.open("calc.txt"); //open file for input

if (!indata){

std::cout<< " Connot open file
";

// handle error

std::cin >> stop;

exit(0);

} // End if

for(i=0; i

indata >> values[i];

} // End for Topology i

for(i=0; i

indata >> rhs[i];

} // End for Topology i

for(i=0; i

indata >> columns[i];

} // End for Topology i

for(i=0; i<=NROWS; i++){

indata >> rowIndex[i];

} // End for Topology i

*/

/* --------------------- */

/* Initialize the solver */

/* --------------------- */

error = dss_create(handle, opt);

if ( error != MKL_DSS_SUCCESS ) goto printError;

/* ------------------------------------------- */

/* Define the non-zero structure of the matrix */

/* ------------------------------------------- */

error = dss_define_structure(

handle, sym, rowIndex_V, nRows_V, nCols_V,

<
P>columns_V, nNonZeros_V );

if ( error != MKL_DSS_SUCCESS ) goto printError;

/*

error = dss_define_structure(

handle, sym, rowIndex_V, nRows_V, nCols_V,

columns_V, nNonZeros_V );

if ( error != MKL_DSS_SUCCESS ) goto printError;

*/

/* ------------------ */

/* Reorder the matrix */

/* ------------------ */

error = dss_reorder( handle, opt, 0);

if ( error != MKL_DSS_SUCCESS ) goto printError;

/* ------------------ */

/* Factor the matrix */

/* ------------------ */

error = dss_factor_real( handle, type, values_v);

if ( error != MKL_DSS_SUCCESS ) goto printError;

/* ------------------------ */

/* Get the solution vector */

/* ------------------------ */

error = dss_solve_real( handle, opt, rhs_V, nRhs, solValues );

if ( error != MKL_DSS_SUCCESS ) goto printError;

/* ------------------------ */

/* Get the determinant */

/*--------------------------*/

error = dss_statistics(handle, opt, statIn, statOut);

if ( error != MKL_DSS_SUCCESS ) goto printError;

/*-------------------------*/

/* print determinant */

/*-------------------------*/

printf(" determinant power is %g
", statOut[0]);

printf(" determinant base is %g
", statOut[1]);

printf(" Determinant is %g
", (pow(10.0,statOut[0]))*statOut[1]);

//free((void *) statIn);

/* -------------------------- */

/* Deallocate solver storage */

/* -------------------------- */

error = dss_delete( handle, opt );

if ( error != MKL_DSS_SUCCESS ) goto printError;

/* ---------------------- */

/* Print solution vector */

/* ---------------------- */

printf(" Solution array: ");

for(i = 0; i< nCols; i++)

printf(" %g", solValues[i] );

printf("
");

exit(0);

printError:

printf("Solver returned error code %d
", error);

exit(1);

}

1 contenuto / 0 nuovi
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione