Commit bc28cfc8 authored by george's avatar george
Browse files

Updates to Kalman filter sylv library

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2780 ac1d8469-bf42-47a9-8791-bf33cf982152
parent b47b9f5e
/* $Header: /var/lib/cvs/dynare_cpp/sylv/cc/SylvException.cpp,v 1.2 2004/10/01 10:30:40 kamenik Exp $ */
/* Tag $Name: $ */
#include "SylvException.h"
#include <string.h>
#include <stdio.h>
SylvException::SylvException(const char* f, int l, const SylvException* s)
{
strcpy(file,f);
line = l;
source = s;
}
SylvException::~SylvException()
{
if (source != NULL) {
delete source;
}
}
void SylvException::printMessage() const
{
char mes[1500];
mes[0] = '\0';
printMessage(mes, 1499);
printf(mes);
}
int SylvException::printMessage(char* str, int maxlen) const
{
int remain = maxlen;
if (source != NULL) {
remain = source->printMessage(str, maxlen);
}
char aux[100];
sprintf(aux, "From %s:%d\n", file, line);
int newremain = remain - strlen(aux);
if (newremain < 0) {
aux[remain] = '\0';
newremain = 0;
}
strcat(str, aux);
return newremain;
}
SylvExceptionMessage::SylvExceptionMessage(const char* f, int i,
const char* mes)
: SylvException(f,i,NULL)
{
strcpy(message,mes);
}
int SylvExceptionMessage::printMessage(char* str, int maxlen) const
{
char aux[600];
sprintf(aux, "At %s:%d:%s\n", file, line, message);
int newremain = maxlen - strlen(aux);
if (newremain < 0) {
aux[maxlen] = '\0';
newremain = 0;
}
strcat(str, aux);
return newremain;
}
/* $Header: /var/lib/cvs/dynare_cpp/sylv/cc/SylvMemory.h,v 1.1.1.1 2004/06/04 13:00:49 kamenik Exp $ */
/* Tag $Name: $ */
#ifndef SYLV_MEMORY_H
#define SYLV_MEMORY_H
//#include "SylvParams.h"
#include <new>
class MallocAllocator {
#ifdef USE_MEMORY_POOL
public:
void* operator new(size_t size);
void* operator new[](size_t size);
void operator delete(void* p);
void operator delete[](void* p);
#endif
};
/*
#ifdef USE_MEMORY_POOL
void* operator new(size_t size);
void* operator new[](size_t size);
void operator delete(void* p);
void operator delete[](void* p);
#endif
class SylvMemoryPool {
char* base;
size_t length;
size_t allocated;
bool stack_mode;
SylvMemoryPool(const SylvMemoryPool&);
const SylvMemoryPool& operator=(const SylvMemoryPool&);
public:
SylvMemoryPool();
~SylvMemoryPool();
void init(size_t size);
void* allocate(size_t size);
void free(void* p);
void reset();
void setStackMode(bool);
};
class SylvMemoryDriver {
SylvMemoryDriver(const SylvMemoryDriver&);
const SylvMemoryDriver& operator=(const SylvMemoryDriver&);
public:
SylvMemoryDriver(int num_d, int m, int n, int order);
SylvMemoryDriver(const SylvParams& pars, int num_d, int m, int n, int order);
static void setStackMode(bool);
~SylvMemoryDriver();
protected:
void allocate(int num_d, int m, int n, int order);
};
*/
#endif /* SYLV_MEMORY_H */
// Local Variables:
// mode:C++
// End:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment