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 "complex.h" | |
#include <math.h> | |
typedef struct COMPLEX { | |
float r, i; | |
} complex; | |
void comPrint(complex a); | |
complex comMul(complex a, complex 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
#!/bin/bash | |
cd /tmp | |
sudo apt-get -y install kdelibs5-dev kdebase-workspace-dev | |
git clone git://anongit.kde.org/kdevplatform | |
cd kdevplatform | |
mkdir build && cd build | |
cmake .. -DCMAKE_INSTALL_PREFIX=/usr | |
make -j8 | |
sudo make install | |
kbuildsycoca4 |
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
require 'torch' | |
_ = require 'moses' | |
csv2tensor = require 'csv2tensor' | |
local dataset = csv2tensor.load('pima-indians-diabetes.data') | |
local trainRatio = 0.67 | |
local dataSize = dataset:size(1) | |
local trainSize = torch.floor(dataSize * trainRatio) | |
local testSize = dataSize - trainSize |
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
#ifndef LINEARREGRESSION_H | |
#define LINEARREGRESSION_H | |
#include "global.h" | |
class LinearRegression | |
{ | |
public: | |
void fit(arma::mat X, const arma::mat& y, double alpha = 0.1, ulong numIterations = 500) { | |
prepareNormalization(X, mu, sigma); |
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
% O primo 41 pode ser escrito como a soma de 6 primos consecutivos | |
% 41 = 2 + 3 + 5 + 7 + 11 + 13 | |
% Essa eh a a soma mais longa de primos consecutivos menor | |
% que 100 em que resulta em tambem em um numero primo, ela contem 6 termos | |
% A soma mais longa de primos consecutivos menor que 1000 em que resulta | |
% um numero primo eh 953 com 21 termos | |
% | |
% Qual primo menor que 1 milhao pode ser escrito como a soma mais longa |
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 | |
interface=eth0 | |
address= | |
gateway= | |
broadcast= | |
netmask= | |
vpn_local=10.0.0.1 | |
vpn_remote=10.0.0.2 | |
ssh_user=root |
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 ../src/arraymancer | |
import math | |
proc `/`*[T: SomeNumber](a: T, t: Tensor[T]): Tensor[T] {.noSideEffect.} = | |
return t.fmap(proc(x: T): T = a / x) | |
proc `+`*[T: SomeNumber](t: Tensor[T], a: T): Tensor[T] {.noSideEffect.} = | |
return t.fmap(proc(x: T): T = x + a) | |
proc `+`*[T: SomeNumber](a: T, t: Tensor[T]): Tensor[T] {.noSideEffect.} = |
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
# Seq of tensors to tensor | |
proc toTensor*[T](s: openarray[Tensor[T]]): Tensor[T] = | |
s.map(proc(t: Tensor[T]): Tensor[T] = t.unsafeUnsqueeze(0)).concat(0) | |
# Make universal does not work with abs | |
proc abs*[T](t: Tensor[T]): Tensor[T] = | |
t.map(proc(x: T):T = abs(x)) | |
# Seq to reshaped tensor, no copy | |
proc unsafeToTensorReshape[T](data: seq[T], shape: openarray[int]): Tensor[T] {.noSideEffect.} = |
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
########## Shape Array | |
const MAXRANK* = 8 | |
type | |
ShapeArray* = object | |
data: array[MAXRANK, int] | |
len: int | |
proc newShapeArray*(len: int): ShapeArray {.inline.} = |
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 sequtils, random | |
proc c_malloc(size: csize): pointer {.importc: "malloc", header: "<stdlib.h>".} | |
proc c_aligned_alloc(alignment, size: csize): pointer {.importc: "aligned_alloc", header: "<stdlib.h>".} | |
proc c_free(p: pointer) {.importc: "free", header: "<stdlib.h>".} | |
proc mkl_malloc(size: csize, align: int): pointer {.importc: "mkl_malloc", header: "<mkl.h>".} | |
proc mkl_free(p: pointer) {.importc: "mkl_free", header: "<mkl.h>".} | |
{.passL:"-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lm".} |
OlderNewer