forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 6:47 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Problem with Cholesky for SPD
PostPosted: Thu Nov 15, 2012 9:31 pm 
Offline

Joined: Thu Nov 15, 2012 9:10 pm
Posts: 1
Hello! first of all were are not sure how to compile using Alglib, here is the code:

Code:
#include "alglibinternal.h"
#include "linalg.h"
#include "ap.h"
#include <fstream>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include "stdafx.h"

using namespace alglib;
using namespace std;


int main(){

   ifstream archivo;
   archivo.open("salida.txt");
   int n,m,NM,N,M;
   string valor,ns,ms,NMS;
   getline(archivo,valor,' ');
   N=atoi(valor.c_str());
   getline(archivo,valor,' ');
   M=atoi(valor.c_str());
   getline(archivo,NMS);
   NM=atoi(NMS.c_str());
   
   double matrix[N][M];
        double *array;
        real_1d_array b;
        array=new double(N*M);

   for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
         matrix[i][j]=0;
      }
   }
   
   while(!archivo.eof()){
      getline(archivo,ns,' ');
      getline(archivo,ms,' ');
      n=atoi(ns.c_str());
      m=atoi(ms.c_str());
      getline(archivo,valor,'\n');
      if(archivo.fail())
         break;
      matrix[n-1][m-1]=atof(valor.c_str());
      
   }
   archivo.close();
   
   for(int i=0,l=0;i<N;i++,l++){
      for(int j=0;j<M;j++){
         array[l]=matrix[i][j];
         l++;
      }
   }

   real_1d_array X;
        real_2d_array A; //<<<<<------ [color=#FF0000]PROBLEM[/color]
   ae_int_t max_fila(N);
   ae_int_t max_columna(M);
   ae_int_t info;
   double r1,rinf;
   //densesolverreport& rep; [color=#0000FF]spdmatrixcholesky need this data type but it doesn't work[/color]
   A.setlength(N,N);
   A.setcontent(max_fila,max_columna,array);
   X.setlength(N);
   for(int i=0; i<N;i++){
      array[i]=0;   
   }
   array[7]=1;
   b.setcontent(N,array);
   
   for(int i=1,l=0;i<10;i++,l++){
      for(int j=1;j<10;j++){
         cout<< A(i,j)<<"\t";
      }
   }
   //spdmatrixcholesky(A, max_fila, false,b,info,rep,X);[color=#0000FF] Is this the right way to use this function[/color]?
        delete [] array;
   return 0;


}


The compilation line throw nothing, but when the program is executed it's aborted, then we runned with ddd, it shows us that the problem is when A (real_2d_array) was declared why is this happening? We use this lines to compile:

Code:
g++ -g ap.cpp  bcsstk01.cpp


The weird thing is that X (real_1d_array) was declared normally.

We are students of a signature named Numerical Analysis, we are using your library to make a project. The matrices we are using are Symetric Positive definite.

PD: i only see that you have Cholesky and Doolitte (the normal LU factorization) but i was wondering if there is a method to solve using Crout (for tridiagonal matrices)

PDD: sorry for our bad english


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group