Skip to content

Instantly share code, notes, and snippets.

@dajuno
dajuno / poission_LRC.py
Created July 7, 2021 09:17
Example for PETSc MatCreateLRC using FEniCS and petsc4py
"""
Solve a simple Poisson system with a low rank update using PETSc MatCreateLRC.
The low rank update is defined at 3 boundaries with different weights, Dirichlet
BC is applied to the other boundary.
https://www.mcs.anl.gov/petsc/petsc-3.13/docs/manualpages/Mat/MatCreateLRC.html
some hints:
https://fenicsproject.discourse.group/t/add-matrix-to-assembled-matrix/122/2
https://lists.mcs.anl.gov/pipermail/petsc-users/2020-February/040228.html
@dajuno
dajuno / nvim.conf
Created March 29, 2022 09:20
neovim config
if &compatible
set nocompatible
endif
filetype plugin indent on
" should be set before loading polyglot
let g:polyglot_disabled = ['yaml', 'latex'] " disable vim-polyglot
call plug#begin('~/.config/nvim/plugged')
@dajuno
dajuno / vec_dot.cpp
Created March 7, 2024 11:58
C++ vs Python vs numpy vs Numba JIT speed comparison
/* compile with:
g++ -O3 -std=c++11 vec_dot.cpp -I/usr/include/openblas -fopenmp -lcblas
(or clang++)
NOTE:
- in main, comment either the OpenMP or the BLAS block! using both leads to degraded performance.
- on my TP X13 G3 with Intel i7-1260P, adding -march=native will lead to lower performance!!
- other flags like -funroll-loops -flto -finline-functions did not seem to lead to significant performance increases
*/