Skip to content

Instantly share code, notes, and snippets.

@mattmcd
mattmcd / HelloEigen.cpp
Last active December 15, 2015 12:39
Installing and testing Eigen3 linear algebra C++ library.
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd; // m by n double matrix
int main()
{
// Example from Eigen3 doc
MatrixXd m(2,2);
// Comma initialization, row major order
@mattmcd
mattmcd / const_forms.cpp
Created March 25, 2013 20:04
Examples of the different uses of const in C++
#include <iostream>
#include <vector>
#include <string>
#include <memory>
typedef std::vector<std::string> str_vec;
void print(str_vec const list)
{
for ( auto el : list ) std::cout << el << std::endl;
@mattmcd
mattmcd / printargs.scala
Last active December 15, 2015 07:59
Scala program to print input arguments on separate lines.
for( arg <- args ) println( arg )
@mattmcd
mattmcd / printargs.cpp
Created March 23, 2013 14:17
C++11 program to print input arguments on separate lines.
#include <iostream>
#include <vector>
#include <string>
int main(int argc, char* argv[])
{
std::vector<std::string> args(argc);
args.assign( argv, argv+argc);
for( const auto arg : args ) std::cout << arg << std::endl;