Skip to content

Instantly share code, notes, and snippets.

Avatar

mk-mode komasaru

View GitHub Profile
@komasaru
komasaru / calc.cpp
Created Oct 15, 2020
C++ source code to calculate a Lorenz attractor by Runge-Kutta's method.
View calc.cpp
#include "calc.hpp"
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <vector>
namespace my_lib {
@komasaru
komasaru / calc.cpp
Created Oct 15, 2020
C++ source code to calculate a Lorenz attractor by Euler's method.
View calc.cpp
#include "calc.hpp"
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <vector>
namespace my_lib {
@komasaru
komasaru / infix2rpn_bt.cpp
Created Oct 13, 2020
C++ source code to convert a formula string to a RPN with a binary tree.
View infix2rpn_bt.cpp
/***************************************************************
Convert an infix formula to an RPN (by binary tree).
(Unary operators are not supported)
DATE AUTHOR VERSION
2020.10.08 mk-mode.com 1.00 新規作成
Copyright(C) 2020 mk-mode.com All Rights Reserved.
***************************************************************/
#include <iostream> // for cout
@komasaru
komasaru / rpn.cpp
Created Oct 12, 2020
C++ source code to calculate a formula expressed with RPN.
View rpn.cpp
/***************************************************************
Caculate a formula string by RPN.
DATE AUTHOR VERSION
2020.10.07 mk-mode.com 1.00 新規作成
Copyright(C) 2020 mk-mode.com All Rights Reserved.
***************************************************************/
#include <iostream> // for cout
#include <regex> // for regex_search.
@komasaru
komasaru / infix2rpn.cpp
Created Oct 12, 2020
C++ source code to convert a formula string to a RPN.
View infix2rpn.cpp
/***************************************************************
Convert an infix formula to an RPN.
(Unary operators are not supported)
DATE AUTHOR VERSION
2020.10.05 mk-mode.com 1.00 新規作成
Copyright(C) 2020 mk-mode.com All Rights Reserved.
***************************************************************/
#include <iostream> // for cout
@komasaru
komasaru / infix2rpn_bt.rb
Last active Oct 8, 2020
Ruby script to convert a formula string to a RPN by binary tree.
View infix2rpn_bt.rb
#! /usr/local/bin/ruby
#*********************************************************
# Ruby script to convert string to RPN (by binary tree).
# (Unary operators are not supported)
#*********************************************************
class Node
attr_reader :expr
def initialize(expr)
@komasaru
komasaru / rpn.rb
Created Oct 2, 2020
Ruby script to calculate a formula expressed with RPN.
View rpn.rb
#! /usr/local/bin/ruby
#*********************************************************
# Ruby script to caculate a formula string by RPN.
#*********************************************************
class String
RE_0 = Regexp.new('[=\s]+$')
RE_1 = Regexp.new('\s+')
RE_D = Regexp.new('\d+')
RE_PL = Regexp.new('\+')
@komasaru
komasaru / infix2rpn.rb
Last active Oct 5, 2020
Ruby script to convert a formula string to a RPN.
View infix2rpn.rb
#! /usr/local/bin/ruby
#*********************************************************
# Ruby script to convert string to RPN.
# (Unary operators are not supported)
#*********************************************************
class String
RE_0 = Regexp.new('\s+|\=')
RE_1 = Regexp.new('[\d\.]+|[()*/+\-]')
RE_D = Regexp.new('\d+')
@komasaru
komasaru / vincenty.cpp
Last active Sep 16, 2020
C++ source code to calculate geodesical values by Vincenty's formulae.(destination)
View vincenty.cpp
#include "vincenty.hpp"
#include <cmath>
#include <iostream>
#include <tuple>
namespace my_lib {
// 定数
constexpr double kA = 6378137.0; // GRS80 長半径
constexpr double kF = 1.0 / 298.257222101; // GRS80 扁平率
@komasaru
komasaru / vincenty.cpp
Created Sep 16, 2020
C++ source code to calculate geodesical values by Vincenty's formulae.(distance)
View vincenty.cpp
#include "vincenty.hpp"
#include <cmath>
#include <iostream>
#include <tuple>
namespace my_lib {
// 定数
constexpr double kA = 6378137.0; // GRS80 長半径
constexpr double kF = 1.0 / 298.257222101; // GRS80 扁平率
You can’t perform that action at this time.