Skip to content

Instantly share code, notes, and snippets.

View Ben1980's full-sized avatar

Benjamin Mahr Ben1980

View GitHub Profile
#include <iostream>
void printTypeSize() {
std::cout << "Size of char = " << sizeof(char) << " byte" << std:: endl;
std::cout << "Size of short = " << sizeof(short) << " byte" << std:: endl;
std::cout << "Size of int = " << sizeof(int) << " byte" << std:: endl;
std::cout << "Size of long = " << sizeof(long) << " byte" << std:: endl;
}
struct S1 {
name: Documentation
on: #(1)
push:
branches:
- master
pull_request:
branches:
- master
page_build:
from lxml import etree
import io
import sys
TAGfile = open(sys.argv[1]+"/Testing/TAG", 'r') #(1)
dirname = TAGfile.readline().strip()
xslfile = open(sys.argv[2], 'r')
xslcontent = xslfile.read()
FROM debian:stable-slim #(1)
LABEL maintainer="ben.mahr@gmail.com" \
description="Image which consists of C++ related build tools." \
version="1.0"
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \ #(2)
git \
openssh-server \
@Ben1980
Ben1980 / config.yml
Last active April 14, 2020 19:02
circleci configuration
version: 2.1
executors: #(1)
exectr:
docker:
- image: dockerben/cpptemplate:latest #(2)
jobs:
build:
executor: exectr #(1)
steps:
namespace CholeskyDecomposition {
template<typename T>
Matrix<T> SimplifySymmetricMatrix(Matrix<T> matrix) {
const size_t nbRows = matrix.rows();
const size_t nbColumns = matrix.columns();
for(size_t row = 0; row < nbRows; ++row) {
for(size_t column = row + 1; column < nbColumns; ++column) {
matrix(row, column) = 0;
}
namespace PivotLUDecomposition {
template<typename T>
struct Decomposition {
Matrix<T> P;
Matrix<T> L;
Matrix<T> U;
Decomposition(const Matrix<T> &matrix) : P(matrix.rows(), matrix.columns()), L(matrix.rows(), matrix.columns()), U(matrix) {}
};
template<typename T>
Decomposition<T> Decompose(const Matrix<T> &matrix) {
const size_t nbRows = matrix.rows();
const size_t nbColumns = matrix.columns();
if(nbRows != nbColumns) {
throw std::domain_error("Matrix is not square.");
}
Decomposition<T> decomposition(matrix);
@Ben1980
Ben1980 / matrix.h
Last active November 14, 2019 19:10
template<typename T>
class Matrix {
static_assert(std::is_arithmetic<T>::value, "T must be numeric");
public:
~Matrix() = default;
Matrix(size_t rows, size_t columns, T *m)
: nbRows(rows), nbColumns(columns), matrix(std::make_unique<T[]>(rows*columns))
{
const size_t size = nbRows*nbColumns;
@Ben1980
Ben1980 / benchmark.cpp
Last active November 13, 2019 05:52
Container benchmark used on http://quick-bench.com
#include <vector>
#include <array>
#include <random>
#include <memory>
#include <algorithm>
const size_t COLUMNS = 500;
const size_t ROWS = 500;
static void TwoDimVector(benchmark::State& state) {