View HSLColor.scala
// HSLColor.scala
// The original code is taken from http://www.camick.com/java/source/HSLColor.java
import java.awt.Color
import math._
object HSLColor {
def RGBtoHSL(r255: Int, g255: Int, b255: Int) : HSLColor = {
val r = r255 / 255f
val g = g255 / 255f
View Fl_create_context.cxx
// The original code is located in
// https://www.khronos.org/opengl/wiki/Tutorial:_OpenGL_3.0_Context_Creation_(GLX)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/gl.h>
View Random.scala
import scala.util.{Random => SRandom}
import java.security.SecureRandom
import org.apache.commons.math3.random.RandomAdaptor
import org.apache.commons.math3.random.MersenneTwister
import org.apache.commons.math3.random.ISAACRandom
object Random {
def MT(seed: Long) : SRandom = new SRandom(new RandomAdaptor(new MersenneTwister(seed)))
def MT : SRandom = MT(new SecureRandom().nextLong())
View get_access_token.groovy
import twitter4j.*
import twitter4j.conf.ConfigurationBuilder
final CONSUMER_KEY = "CONSUMER_KEY"
final CONSUMER_SECRET = "CONSUMER_SECRET"
cb = new ConfigurationBuilder()
cb.setDebugEnabled(true)
.setOAuthConsumerKey(CONSUMER_KEY)
.setOAuthConsumerSecret(CONSUMER_SECRET)
View acceldif.R
# acceldif.R
printf = function(...) invisible(print(sprintf(...)))
R = 1:20
H = 2^(-(R+2))
f = function(x) exp(x)
err = function(x) abs(x - f(1)) / f(1)
View acceldif.jl
#acceldif.jl
R = 1:20
h = [2.0^(-k) for k in R + 2]
f(x) = exp(x)
err(x) = abs(x - f(1)) / f(1)
dif_f(h) = (f(1 + h) - f(1)) / h
dif(h) = (f(1 + h) - f(1 - h)) / 2h
View sse2test.cpp
#include <stdio.h>
#include <random>
#include "mytimer.h"
typedef double v2df __attribute__ ((vector_size (16)));
#define N 10000000
#define AL 16
#define HNK 139079.0
View mydouble.h
#include <stdio.h>
#include <math.h>
typedef double PrimDouble;
struct MyDouble {
PrimDouble v;
static const int precision = 23;
MyDouble() { v = 0; }
View mytimer.h
#include <stdio.h>
#include <chrono>
class MyTimer {
std::chrono::system_clock::time_point s;
double ms;
public:
inline void start() {
s = std::chrono::system_clock::now();
}
View bfi.plt
#bfi.plt
load "bfi_init.plt"
load "bfi_run.plt"