Commit efb0bb4a authored by Dmitry Bagaev's avatar Dmitry Bagaev

CLion code style reformat

parent 9705cf97
set(SOURCE
${SOURCE}
${CMAKE_CURRENT_SOURCE_DIR}/Solver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SolverFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sparse.cpp
)
${SOURCE}
${CMAKE_CURRENT_SOURCE_DIR}/Solver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SolverFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sparse.cpp
)
set(HEADER
${HEADER}
${CMAKE_CURRENT_SOURCE_DIR}/SolverFactory.h
)
${HEADER}
${CMAKE_CURRENT_SOURCE_DIR}/SolverFactory.h
)
add_subdirectory(solver_inner)
if(USE_SOLVER_PETSC)
add_subdirectory(solver_petsc)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.hpp" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.cpp" )
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_MPTILUC2)
set(HAVE_SOLVER_MPTILUC2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.hpp)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.cpp)
else()
set(HAVE_SOLVER_MPTILUC2 FALSE PARENT_SCOPE)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.hpp" )
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_MPTILU2)
set(HAVE_SOLVER_MPTILU2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.hpp)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.cpp)
else()
set(HAVE_SOLVER_MPTILU2 FALSE PARENT_SCOPE)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.h" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.cpp" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fcbiilu2.cpp" )
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_FCBIILU2)
set(HAVE_SOLVER_FCBIILU2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.h)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fcbiilu2.cpp)
else()
set(HAVE_SOLVER_FCBIILU2 FALSE)
endif()
if (USE_SOLVER_PETSC)
add_subdirectory(solver_petsc)
endif ()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.hpp" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.cpp")
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_MPTILUC2)
set(HAVE_SOLVER_MPTILUC2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.hpp)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.cpp)
else ()
set(HAVE_SOLVER_MPTILUC2 FALSE PARENT_SCOPE)
endif ()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.hpp")
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_MPTILU2)
set(HAVE_SOLVER_MPTILU2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.hpp)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.cpp)
else ()
set(HAVE_SOLVER_MPTILU2 FALSE PARENT_SCOPE)
endif ()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.h" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.cpp" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fcbiilu2.cpp")
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_FCBIILU2)
set(HAVE_SOLVER_FCBIILU2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.h)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fcbiilu2.cpp)
else ()
set(HAVE_SOLVER_FCBIILU2 FALSE)
endif ()
if (USE_MPI)
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.h" AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.cpp" AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/k3d.h" AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/k3d.cpp" )
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_K3BIILU2)
set(HAVE_SOLVER_K3BIILU2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.h ${CMAKE_CURRENT_SOURCE_DIR}/k3d.h)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/k3d.cpp)
else()
set(HAVE_SOLVER_K3BIILU2 FALSE PARENT_SCOPE)
endif()
endif()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.h" AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.cpp" AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/k3d.h" AND EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/k3d.cpp")
set(SOLVER_DEFINITIONS ${SOLVER_DEFINITIONS} -DHAVE_SOLVER_K3BIILU2)
set(HAVE_SOLVER_K3BIILU2 TRUE PARENT_SCOPE)
list(APPEND HEADER ${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.h ${CMAKE_CURRENT_SOURCE_DIR}/k3d.h)
list(APPEND SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/k3d.cpp)
else ()
set(HAVE_SOLVER_K3BIILU2 FALSE PARENT_SCOPE)
endif ()
endif ()
set(HEADER ${HEADER} PARENT_SCOPE)
......
......@@ -41,6 +41,5 @@ namespace INMOST {
}
}
......@@ -6,17 +6,20 @@
namespace INMOST {
struct SolverBaseFactory {
virtual SolverInterface* create() = 0;
virtual SolverInterface* copy(const SolverInterface* other) = 0;
virtual SolverInterface *create() = 0;
virtual SolverInterface *copy(const SolverInterface *other) = 0;
virtual ~SolverBaseFactory() {};
};
template <class C> struct SolverCreateFactory : SolverBaseFactory {
template<class C>
struct SolverCreateFactory : SolverBaseFactory {
SolverInterface *create() {
return new C;
};
SolverInterface *copy(const SolverInterface* other) {
SolverInterface *copy(const SolverInterface *other) {
return new C(other);
};
};
......@@ -25,12 +28,17 @@ namespace INMOST {
private:
static std::map<std::string, SolverBaseFactory *> solvers;
public:
template<class T> static void registerSolver(std::string name) {
template<class T>
static void registerSolver(std::string name) {
solvers.insert(std::make_pair(name, new SolverCreateFactory<T>));
};
static SolverInterface *getSolver(std::string name);
static SolverInterface *copySolver(const SolverInterface *other);
static std::vector<std::string> getAvailableSolvers();
static bool isSolverAvailable(std::string name);
};
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,144 +2,144 @@
namespace INMOST {
SolverILU2::SolverILU2() {
additive_schwartz_overlap = DEFAULT_ADDITIVE_SCHWARTZ_OVERLAP;
maximum_iterations = DEFAULT_MAXIMUM_ITERATIONS;
absolute_tolerance = DEFAULT_ABSOLUTE_TOLERANCE;
relative_tolerance = DEFAULT_RELATIVE_TOLERANCE;
divergence_tolerance = DEFAULT_DIVERGENCE_TOLERANCE;
preconditioner_drop_tolerance = DEFAULT_PRECONDITIONER_DROP_TOLERANCE;
preconditioner_reuse_tolerance = DEFAULT_PRECONDITIONER_REUSE_TOLERANCE;
preconditioner_rescale_iterations = DEFAULT_PRECONDITIONER_RESCALE_ITERS;
preconditioner_fill_level = DEFAULT_PRECONDITIONER_FILL_LEVEL;
Method *prec = new ILU2_preconditioner(info);
solver = new BCGS_solver(prec, info);
matrix = NULL;
}
SolverILU2::SolverILU2(const SolverInterface* other) {
//You should not really want to copy solver's information
throw INMOST::SolverUnsupportedOperation;
SolverILU2::SolverILU2() {
additive_schwartz_overlap = DEFAULT_ADDITIVE_SCHWARTZ_OVERLAP;
maximum_iterations = DEFAULT_MAXIMUM_ITERATIONS;
absolute_tolerance = DEFAULT_ABSOLUTE_TOLERANCE;
relative_tolerance = DEFAULT_RELATIVE_TOLERANCE;
divergence_tolerance = DEFAULT_DIVERGENCE_TOLERANCE;
preconditioner_drop_tolerance = DEFAULT_PRECONDITIONER_DROP_TOLERANCE;
preconditioner_reuse_tolerance = DEFAULT_PRECONDITIONER_REUSE_TOLERANCE;
preconditioner_rescale_iterations = DEFAULT_PRECONDITIONER_RESCALE_ITERS;
preconditioner_fill_level = DEFAULT_PRECONDITIONER_FILL_LEVEL;
Method *prec = new ILU2_preconditioner(info);
solver = new BCGS_solver(prec, info);
matrix = NULL;
}
SolverILU2::SolverILU2(const SolverInterface *other) {
//You should not really want to copy solver's information
throw INMOST::SolverUnsupportedOperation;
}
void SolverILU2::Assign(const SolverInterface *other) {
//You should not really want to copy solver's information
throw INMOST::SolverUnsupportedOperation;
}
void SolverILU2::Initialize(int *argc, char ***argv, const char *parameters_file, std::string prefix) {
}
void SolverILU2::SetMatrix(Sparse::Matrix &A, bool ModifiedPattern, bool OldPreconditioner) {
Sparse::Matrix *m = new Sparse::Matrix(A);
info.PrepareMatrix(*m, additive_schwartz_overlap);
solver->ReplaceMAT(*m);
if (matrix != NULL) {
delete matrix;
}
matrix = m;
void SolverILU2::Assign(const SolverInterface* other) {
//You should not really want to copy solver's information
throw INMOST::SolverUnsupportedOperation;
}
solver->RealParameter(":tau") = preconditioner_drop_tolerance;
solver->RealParameter(":tau2") = preconditioner_reuse_tolerance;
solver->EnumParameter(":scale_iters") = preconditioner_rescale_iterations;
solver->EnumParameter(":fill") = static_cast<INMOST_DATA_ENUM_TYPE>(preconditioner_fill_level);
void SolverILU2::Initialize(int *argc, char ***argv, const char *parameters_file, std::string prefix) {
}
void SolverILU2::SetMatrix(Sparse::Matrix & A, bool ModifiedPattern, bool OldPreconditioner) {
Sparse::Matrix *m = new Sparse::Matrix(A);
info.PrepareMatrix(*m, additive_schwartz_overlap);
solver->ReplaceMAT(*m);
if (matrix != NULL) {
delete matrix;
}
matrix = m;
solver->RealParameter(":tau") = preconditioner_drop_tolerance;
solver->RealParameter(":tau2") = preconditioner_reuse_tolerance;
solver->EnumParameter(":scale_iters") = preconditioner_rescale_iterations;
solver->EnumParameter(":fill") = static_cast<INMOST_DATA_ENUM_TYPE>(preconditioner_fill_level);
if (!solver->isInitialized()) {
solver->Initialize();
}
}
bool SolverILU2::Solve(Sparse::Vector &RHS, Sparse::Vector &SOL) {
solver->EnumParameter("maxits") = maximum_iterations;
solver->RealParameter("rtol") = relative_tolerance;
solver->RealParameter("atol") = absolute_tolerance;
solver->RealParameter("divtol") = divergence_tolerance;
return solver->Solve(RHS,SOL);
if (!solver->isInitialized()) {
solver->Initialize();
}
bool SolverILU2::Clear() {
info.Clear();
if (matrix != NULL) {
delete matrix;
matrix = NULL;
}
if (solver != NULL) {
delete solver;
solver = NULL;
}
return true;
}
bool SolverILU2::Solve(Sparse::Vector &RHS, Sparse::Vector &SOL) {
solver->EnumParameter("maxits") = maximum_iterations;
solver->RealParameter("rtol") = relative_tolerance;
solver->RealParameter("atol") = absolute_tolerance;
solver->RealParameter("divtol") = divergence_tolerance;
return solver->Solve(RHS, SOL);
}
bool SolverILU2::Clear() {
info.Clear();
if (matrix != NULL) {
delete matrix;
matrix = NULL;
}
bool SolverILU2::isMatrixSet() {
return matrix != NULL;
}
INMOST_DATA_REAL_TYPE SolverILU2::GetPropertyReal(std::string property) const {
return solver->RealParameter(property);
}
INMOST_DATA_ENUM_TYPE SolverILU2::GetPropertyEnum(std::string property) const {
return solver->EnumParameter(property);
}
void SolverILU2::SetPropertyReal(std::string property, INMOST_DATA_REAL_TYPE value) {
//Maybe we should use explicit names?, like maxits ..etc
//like solver->RealParameter(property) = value;
if (property == "absolute_tolerance") {
absolute_tolerance = value;
} else if (property == "relative_tolerance") {
relative_tolerance = value;
} else if (property == "divergence_tolerance") {
divergence_tolerance = value;
} else if (property == "drop_tolerance") {
preconditioner_drop_tolerance = value;
} else if (property == "reuse_tolerance") {
preconditioner_reuse_tolerance = value;
} else if (property == "fill_level") {
preconditioner_fill_level = value;
} else {
std::cout << "Parameter " << property << " of real type is unknown" << std::endl;
}
}
void SolverILU2::SetPropertyEnum(std::string property, INMOST_DATA_ENUM_TYPE value) {
//Maybe we should use explicit names?, like maxits ..etc
//like solver->EnumParameter(property) = value;
if (property == "maximum_iterations") {
maximum_iterations = value;
} else if (property == "rescale_iterations") {
preconditioner_rescale_iterations = value;
} else if (property == "schwartz_overlap") {
additive_schwartz_overlap = value;
} else std::cout << "Parameter " << property << " of integral type is unknown" << std::endl;
if (solver != NULL) {
delete solver;
solver = NULL;
}
const INMOST_DATA_ENUM_TYPE SolverILU2::Iterations() const {
return solver->GetIterations();
}
const INMOST_DATA_REAL_TYPE SolverILU2::Residual() const {
return solver->GetResidual();
}
const std::string SolverILU2::ReturnReason() const {
return solver->GetReason();
}
const std::string SolverILU2::SolverName() const {
return "inner_ilu2";
}
void SolverILU2::Finalize() {
}
SolverILU2::~SolverILU2() {
Clear();
return true;
}
bool SolverILU2::isMatrixSet() {
return matrix != NULL;
}
INMOST_DATA_REAL_TYPE SolverILU2::GetPropertyReal(std::string property) const {
return solver->RealParameter(property);
}
INMOST_DATA_ENUM_TYPE SolverILU2::GetPropertyEnum(std::string property) const {
return solver->EnumParameter(property);
}
void SolverILU2::SetPropertyReal(std::string property, INMOST_DATA_REAL_TYPE value) {
//Maybe we should use explicit names?, like maxits ..etc
//like solver->RealParameter(property) = value;
if (property == "absolute_tolerance") {
absolute_tolerance = value;
} else if (property == "relative_tolerance") {
relative_tolerance = value;
} else if (property == "divergence_tolerance") {
divergence_tolerance = value;
} else if (property == "drop_tolerance") {
preconditioner_drop_tolerance = value;
} else if (property == "reuse_tolerance") {
preconditioner_reuse_tolerance = value;
} else if (property == "fill_level") {
preconditioner_fill_level = value;
} else {
std::cout << "Parameter " << property << " of real type is unknown" << std::endl;
}
}
void SolverILU2::SetPropertyEnum(std::string property, INMOST_DATA_ENUM_TYPE value) {
//Maybe we should use explicit names?, like maxits ..etc
//like solver->EnumParameter(property) = value;
if (property == "maximum_iterations") {
maximum_iterations = value;
} else if (property == "rescale_iterations") {
preconditioner_rescale_iterations = value;
} else if (property == "schwartz_overlap") {
additive_schwartz_overlap = value;
} else std::cout << "Parameter " << property << " of integral type is unknown" << std::endl;
}
const INMOST_DATA_ENUM_TYPE SolverILU2::Iterations() const {
return solver->GetIterations();
}
const INMOST_DATA_REAL_TYPE SolverILU2::Residual() const {
return solver->GetResidual();
}
const std::string SolverILU2::ReturnReason() const {
return solver->GetReason();
}
const std::string SolverILU2::SolverName() const {
return "inner_ilu2";
}
void SolverILU2::Finalize() {
}
SolverILU2::~SolverILU2() {
Clear();
}
}
\ No newline at end of file
......@@ -12,19 +12,19 @@ namespace INMOST {
SolverPETSc::SolverPETSc(const SolverInterface *other) {
petscSolversCount++;
const SolverPETSc *solver = static_cast<const SolverPETSc*>(other);
const SolverPETSc *solver = static_cast<const SolverPETSc *>(other);
this->ksp = NULL;
this->matrix = NULL;
SolverCopyDataPetsc(&ksp, solver->ksp, solver->communicator);
if (solver->matrix != NULL) {
MatrixCopyDataPetsc(&matrix, solver->matrix);
SolverSetMatrixPetsc(ksp, matrix,false,false);
SolverSetMatrixPetsc(ksp, matrix, false, false);
}
}
void SolverPETSc::Assign(const SolverInterface *other) {
const SolverPETSc *other_solver = static_cast<const SolverPETSc*>(other);
const SolverPETSc *other_solver = static_cast<const SolverPETSc *>(other);
this->parametersFile = other_solver->parametersFile;
SolverAssignDataPetsc(ksp, other_solver->ksp);
if (other_solver->matrix != NULL) {
......@@ -43,53 +43,53 @@ namespace INMOST {
SolverInitDataPetsc(&ksp, this->communicator, prefix.c_str());
}
void SolverPETSc::SetMatrix(Sparse::Matrix & A, bool ModifiedPattern, bool OldPreconditioner) {
void SolverPETSc::SetMatrix(Sparse::Matrix &A, bool ModifiedPattern, bool OldPreconditioner) {
bool modified_pattern = ModifiedPattern;
if( !isMatrixSet()) {
MatrixInitDataPetsc(&matrix, A.GetCommunicator(),A.GetName().c_str());
if (!isMatrixSet()) {
MatrixInitDataPetsc(&matrix, A.GetCommunicator(), A.GetName().c_str());
modified_pattern = true;
}
INMOST_DATA_ENUM_TYPE mbeg,mend;
A.GetInterval(mbeg,mend);
if( modified_pattern ) {
INMOST_DATA_ENUM_TYPE mbeg, mend;
A.GetInterval(mbeg, mend);
if (modified_pattern) {
local_size = A.Size();
#if defined(USE_MPI)
MPI_Allreduce(&local_size,&global_size,1,INMOST_MPI_DATA_ENUM_TYPE,MPI_SUM, this->communicator);
MPI_Allreduce(&local_size, &global_size, 1, INMOST_MPI_DATA_ENUM_TYPE, MPI_SUM, this->communicator);
#else
global_size = local_size;
#endif
int max = 0;
{
int * diag_nonzeroes = new int[local_size];
int * off_diag_nonzeroes = new int[local_size];
int *diag_nonzeroes = new int[local_size];
int *off_diag_nonzeroes = new int[local_size];
unsigned k = 0;
for(Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
for (Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
diag_nonzeroes[k] = off_diag_nonzeroes[k] = 0;
for(INMOST_DATA_ENUM_TYPE i = 0; i < it->Size(); i++) {
for (INMOST_DATA_ENUM_TYPE i = 0; i < it->Size(); i++) {
INMOST_DATA_ENUM_TYPE index = it->GetIndex(i);
if( index < mbeg || index > mend-1 ) {
if (index < mbeg || index > mend - 1) {
off_diag_nonzeroes[k]++;
} else {
diag_nonzeroes[k]++;
}
}
if( diag_nonzeroes[k] + off_diag_nonzeroes[k] > max ) {
if (diag_nonzeroes[k] + off_diag_nonzeroes[k] > max) {
max = diag_nonzeroes[k] + off_diag_nonzeroes[k];
}
k++;
}
MatrixPreallocatePetsc(matrix, local_size, global_size, diag_nonzeroes, off_diag_nonzeroes);
delete [] diag_nonzeroes;
delete [] off_diag_nonzeroes;
delete[] diag_nonzeroes;
delete[] off_diag_nonzeroes;
}
if( max > 0 ) {
int * col_positions = new int[max];
double * col_values = new double[max];
if (max > 0) {
int *col_positions = new int[max];
double *col_values = new double[max];
unsigned k = 0, m;
for(Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
for (Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
m = 0;
for(INMOST_DATA_ENUM_TYPE i = 0; i < it->Size(); i++) {
for (INMOST_DATA_ENUM_TYPE i = 0; i < it->Size(); i++) {
col_positions[m] = it->GetIndex(i);
col_values[m] = it->GetValue(i);
m++;
......@@ -97,22 +97,22 @@ namespace INMOST {
MatrixFillPetsc(matrix, mbeg + k, m, col_positions, col_values);
k++;
}
delete [] col_positions;
delete [] col_values;
delete[] col_positions;
delete[] col_values;
}
} else {
unsigned max = 0;
for(Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
if( it->Size() > max ) {
for (Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
if (it->Size() > max) {
max = it->Size();
}
}
int * col_positions = new int[max];
double * col_values = new double[max];
int *col_positions = new int[max];
double *col_values = new double[max];
unsigned k = 0, m;
for(Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
for (Sparse::Matrix::iterator it = A.Begin(); it != A.End(); ++it) {
m = 0;
for(INMOST_DATA_ENUM_TYPE i = 0; i < it->Size(); i++) {
for (INMOST_DATA_ENUM_TYPE i = 0; i < it->Size(); i++) {
col_positions[m] = it->GetIndex(i);
col_values[m] = it->GetValue(i);
m++;
......@@ -120,8 +120,8 @@ namespace INMOST {
MatrixFillPetsc(matrix, mbeg + k, m, col_positions, col_values);
k++;
}
delete [] col_positions;
delete [] col_values;
delete[] col_positions;
delete[] col_values;
}
MatrixFinalizePetsc(matrix);
......@@ -141,13 +141,13 @@ namespace INMOST {
Vec *solution = NULL;
VectorInitDataPetsc(&solution, SOL.GetCommunicator(), SOL.GetName().c_str());
VectorPreallocatePetsc(solution, local_size, global_size);
INMOST_DATA_ENUM_TYPE vbeg,vend;
RHS.GetInterval(vbeg,vend);
int * positions = new int[local_size];
double * values = new double[local_size];
INMOST_DATA_ENUM_TYPE vbeg, vend;
RHS.GetInterval(vbeg, vend);
int *positions = new int[local_size];
double *values = new double[local_size];
unsigned int k = 0;
for(Sparse::Vector::iterator it = RHS.Begin(); it != RHS.End(); ++it) {
positions[k] = vbeg+k;
for (Sparse::Vector::iterator it = RHS.Begin(); it != RHS.End(); ++it) {
positions[k] = vbeg + k;
values[k] = *it;
k++;
}
......@@ -155,7 +155,7 @@ namespace INMOST {
VectorFinalizePetsc(rhs);
k = 0;
for(Sparse::Vector::iterator it = SOL.Begin(); it != SOL.End(); ++it) {
for (Sparse::Vector::iterator it = SOL.Begin(); it != SOL.End(); ++it) {
values[k] = *it;
k++;
}
......@@ -174,15 +174,15 @@ namespace INMOST {
if (result) {
VectorLoadPetsc(solution, local_size, positions, values);
k = 0;
for(Sparse::Vector::iterator it = SOL.Begin(); it != SOL.End(); ++it) {
for (Sparse::Vector::iterator it = SOL.Begin(); it != SOL.End(); ++it) {
*it = values[k];
k++;
}
}
VectorDestroyDataPetsc(&rhs);
VectorDestroyDataPetsc(&solution);
delete [] positions;
delete [] values;
delete[] positions;
delete[] values;
return result;
}
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
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