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
(*--------------------------------------------------------------------------- | |
Copyright (c) 2015 Daniel C. Bünzli. All rights reserved. | |
Distributed under the BSD3 license, see license at the end of the file. | |
%%NAME%% release %%VERSION%% | |
---------------------------------------------------------------------------*) | |
(* Simple generators according to: | |
Kiselyov, Peyton-Jones, Sabry | |
Lazy v. Yield: Incremental, Linear Pretty-printing |
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
struct btree_node | |
{ | |
struct btree_node * u_left; | |
struct btree_node * u_right; | |
int32_t u_data; | |
}; | |
typedef struct btree_node btree_node; | |
typedef struct btree_node btree; | |
typedef struct btree_node * btree_forest; |
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
# define BINARYTREE_MAXDEPTH 1024 | |
# define RDFOREST_MAXTREE 216 | |
# define RDFOREST_MAXSELECTION 512 | |
# define RDFOREST_MAXBAG 128 | |
struct btree | |
{ | |
int32_t u_data[BINARYTREE_MAXDEPTH]; | |
int32_t u_length; | |
}; |
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
static inline | |
void timeval_to_timespec(const struct timeval * tv, struct timespec * ts) | |
{ | |
ts->tv_sec = tv->tv_sec; | |
ts->tv_nsec = tv->tv_usec * 1000; | |
} | |
static inline | |
void timespec_to_timeval(const struct timespec * ts, struct timeval * tv) | |
{ |
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
template <class T | |
//cpp11 , typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr | |
> | |
T fma(const T& x, const T& y, const T& z) | |
{ | |
const T cs = TwoProduct<T>::split_value; | |
T s = z, w = T(0), h, q, r, x1, x2, y1, y2; | |
// can be a loop where x and y are values at index and w, s are accumulators. fmav. |
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
// ML Reminder, educational. | |
static | |
float __linear_learner_gradient_descent( | |
const unsigned int n | |
, const float * x | |
, const float * y | |
, const float rate | |
, float * a | |
, float * b |
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 <stdio.h> | |
#include <stdlib.h> | |
# define stl_scope_begin do { | |
# define stl_scope_end break; } while (0) | |
# define stl_basic_swap(_Tp, __a, __b) \ | |
stl_scope_begin \ | |
_Tp __stl_c = (__a); \ | |
(__a) = (__b); \ |
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
import numpy as np | |
class pca: | |
def __svd_thin(self, a): | |
u, s, vh = np.linalg.svd(a, full_matrices=False, compute_uv=True) | |
return ( u, s, vh.T ) | |
def __eig_symmetric(self, a): | |
c = np.dot(a.T, a) / (a.shape[0] - 1) | |
e, v = np.linalg.eig(c) |
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 <io.h> | |
#include <fileapi.h> | |
#include <string.h> | |
static int errno_table[] = | |
{ | |
0 | |
, EINVAL /* ERROR_INVALID_FUNCTION, 1 */ | |
, ENOENT /* ERROR_FILE_NOT_FOUND, 2 */ | |
, ENOENT /* ERROR_PATH_NOT_FOUND, 3 */ |
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
// flock_win32.h | |
# ifndef LOCK_SH | |
# define LOCK_SH 1 | |
# define LOCK_EX 2 | |
# define LOCK_NB 4 | |
# define LOCK_UN 8 | |
# endif | |
int __cdecl flock(int fd, int operation); |
OlderNewer