Skip to content

Commit

Permalink
Remove ldlt-allocator.cpp
Browse files Browse the repository at this point in the history
+ change create_default_block_structure to be inline
  • Loading branch information
ManifoldFR committed Nov 24, 2023
1 parent fc5e7a0 commit e990529
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 59 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ endif(BUILD_WITH_PINOCCHIO_SUPPORT)
set(LIB_HEADER_DIR ${PROJECT_SOURCE_DIR}/include/proxnlp)
file(GLOB_RECURSE LIB_HEADERS ${LIB_HEADER_DIR}/*.hpp ${LIB_HEADER_DIR}/*.hxx)

set(LIB_SOURCES ${PROJECT_SOURCE_DIR}/src/block-kind.cpp
${PROJECT_SOURCE_DIR}/src/ldlt-allocator.cpp)
set(LIB_SOURCES ${PROJECT_SOURCE_DIR}/src/block-kind.cpp)

if(ENABLE_TEMPLATE_INSTANTIATION)

Expand Down
49 changes: 47 additions & 2 deletions include/proxnlp/ldlt-allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,54 @@ enum class LDLTChoice {
PROXSUITE
};

SymbolicBlockMatrix
inline SymbolicBlockMatrix
create_default_block_structure(const std::vector<isize> &dims_primal,
const std::vector<isize> &dims_dual);
const std::vector<isize> &dims_dual) {

using linalg::BlockKind;

isize nprim_blocks = (isize)dims_primal.size();
isize ndual_blocks = (isize)dims_dual.size();
isize nblocks = nprim_blocks + ndual_blocks;

SymbolicBlockMatrix structure(nblocks, nblocks);
isize *segment_lens = structure.segment_lens;

for (unsigned int i = 0; i < nprim_blocks; ++i) {
segment_lens[i] = dims_primal[i];
}
for (unsigned int i = 0; i < ndual_blocks; ++i) {
segment_lens[i + nprim_blocks] = dims_dual[i];
}

// default structure: primal blocks are dense, others are sparse

for (isize i = 0; i < nprim_blocks; ++i) {
for (isize j = 0; j < nprim_blocks; ++j) {
structure(i, j) = linalg::Dense;
}
}

// jacobian blocks: assumed dense
for (isize i = 0; i < nprim_blocks; ++i) {
for (isize j = nprim_blocks; j < nblocks; ++j) {
structure(i, j) = linalg::Dense;
structure(j, i) = linalg::Dense;
}
}

for (isize i = nprim_blocks; i < nblocks; ++i) {
// diagonal blocks are diagonal
structure(i, i) = linalg::Diag;

// off-diagonal blocks are zero
for (isize j = nprim_blocks; j < nblocks; ++j) {
if (i != j)
structure(i, j) = linalg::Zero;
}
}
return structure;
}

inline isize get_total_dim_helper(const std::vector<isize> &nprims,
const std::vector<isize> &nduals) {
Expand Down
55 changes: 0 additions & 55 deletions src/ldlt-allocator.cpp

This file was deleted.

0 comments on commit e990529

Please sign in to comment.