This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tuple> | |
#include <type_traits> | |
template <typename T, typename U> | |
struct concatenate_tuple {}; | |
template <typename... Ts, typename... Us> | |
struct concatenate_tuple<std::tuple<Ts...>, std::tuple<Us...>> { | |
using type = std::tuple<Ts..., Us...>; | |
}; | |
template <typename T, typename U> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Eigen/Core> | |
#include <numeric> | |
#include <tuple> | |
#include <iterator> | |
#include <algorithm> | |
#include <iostream> | |
template <typename BeginIt, typename EndIt> | |
auto vstack_iter(BeginIt beginit, EndIt endit) { | |
using CDerived = typename std::decay_t<decltype(*beginit)>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <spdlog/spdlog.h> | |
#include <functional> | |
#include <map> | |
#include <type_traits> | |
#include <utility> | |
#include <variant> | |
// Say you have a few heavy data structures derived from a single base class | |
// that has a value/enum that can be used to identify which derived class you have. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Eigen/Core> | |
#include <concepts> | |
#include <iostream> | |
// This example code shows how concepts could be used to lighten the syntax used | |
// in declaring igl style function input/outputs. In particular, inputs are | |
// typically derived from MatrixBase (which can be accessed directly) and | |
// outputs are derived from PlainObjectBase (which has memory to store values). | |
// | |
// Below there are three examples: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Changes brightness as a float value in [0,1], using +N -N induces a relative | |
# change in brightness | |
# Usage: | |
# brightness.sh .8 # set brightness to .8 | |
# brightness.sh -.1 # decrement brightness by .1 | |
# brightness.sh +.1 # increment brightness by .1 | |
# helper to do floating point evaluation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <Eigen/Dense> | |
#include <concepts> | |
namespace Eigen { | |
template <int D, typename Derived> | |
inline auto& get(Eigen::DenseCoeffsBase<Derived, WriteAccessors>& p) { return p.coeffRef(D); } | |
template <int D, typename Derived> | |
inline const auto get(const Eigen::DenseCoeffsBase<Derived,ReadOnlyAccessors>& p) { return p.coeff(D); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <set> | |
#include <tuple> | |
// all caching classes need to have a basic inventory of dirty flags and a tool | |
// to flush them. | |
class CachableType { | |
template <typename RetType, typename... Args> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compiled with `clang++ -O3 -std=c++17 -march=native igl_mesh_read_test.cpp -o igl_mesh_read_test` | |
Hit something unexpected (unless i'm doing something stupid). In particular, the cost of pre-reading a file to pre-allocate the `vector<vector<double>>` data outweighs the cost of reading in a mesh. Changing the data type that the loader assumes is of size 3 to `vector<array<double,3>` increased performance. I thought that increasing the size of the heap objects being allocated would make pre-sizing more important but it didn't; in fact my preliminary tests said that it made results even slower. My methodology of using `reserve()` then `.push_back` could be faulty (perhaps `resize()` -> `value[idx] = val` will actually work better? | |
Format of the results are "igl base impl || vector file scan || array file scan || just with array" | |
File /home/mtao/Downloads/20131013_Venus2.obj took 2576 || 2733 || 2701 || 2503.33 ms/load (7728 || 8200 || 8105 || 7510ms total) | |
File /home/mtao/git/quartet/meshes/block.obj took 61 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Eigen/Dense> | |
#include <cassert> | |
#include <iostream> | |
// the ideal way to implement a cross product function is to depend on eigen's | |
// builtin | |
template <typename XDerived, typename YDerived> | |
auto cross_t(const Eigen::MatrixBase<XDerived>& x, | |
const Eigen::MatrixBase<YDerived>& y) { | |
return x.cross(y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "A.h" | |
#include <iostream> | |
class A_impl { | |
public: | |
void f() const { | |
std::cout << "F!" << std::endl; | |
} | |
}; | |
A::A(): _obj{std::make_unique<A_impl>()} {} |
NewerOlder