Skip to content

Instantly share code, notes, and snippets.

View ezander's full-sized avatar
🏠
Working from home

Elmar Zander ezander

🏠
Working from home
View GitHub Profile
@ezander
ezander / Eigen Cheat sheet.cpp
Last active January 11, 2022 13:43 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@ezander
ezander / C++ class layout.cpp
Last active January 11, 2022 13:43
C++ class layout without virtual functions
#include <iostream>
using namespace std;
class A {
public:
int x;
void f() {};
};
@ezander
ezander / Decorator that checks return value and changes docstring.py
Last active January 11, 2022 13:45
decorator with change of docstring
import functools
import unittest
from pydoc import render_doc
def returns(t):
def checktype(func):
def checked_func(*args, **kwargs):
rval = func(*args, **kwargs)
if not isinstance(rval, t):
raise TypeError("Return type is not of type: int but of type "