Commit 545565f0 authored by Arnaud Blanchard's avatar Arnaud Blanchard

Introduce armdillo and Z transform

parent 0276bedc
......@@ -14,8 +14,7 @@
#include <time.h>
#include <math.h>
#include <armadillo>
using namespace arma;
#include <vector>
......@@ -100,6 +99,8 @@ inline void Ohm_input::spike(){
/*index++;
if (index==buffer_size) index=0;*/
// activated=tau/ns_per_it;
activated=1;
}
......@@ -130,8 +131,7 @@ void *thread_loop(void*){
// initial_us=3000000*(int)(*raspi.ptime_us/3000000)-3000000;
// update_time();
vec A = linspace(0.9, 1.1, 10);
for(auto &input : ohm_inputs){
*raspi.gpfset0|=input.flag; //Set pin high
raspi.set_pin_mode(input.pin, raspi.PULL_OFF);
......
......@@ -14,6 +14,8 @@
#include "blc_program.h"
#include "blc_channel.h"
#include "bl_raspi.h"
#include <armadillo>
static const int SOUND_PIN=13;
......@@ -23,6 +25,7 @@ static const int LEFT_MOTOR_PIN=26;
static const int RIGHT_MOTOR_PIN=20;
using namespace std;
using namespace arma;
static uchar gaussian_cdf(uint32_t s, float mu, float var){
return static_cast<uchar>((1+erf((s-mu)/sqrt(2*var)))*255/2); //var+1 is to be sure it is not null
......@@ -144,6 +147,20 @@ int main(int argc, char **argv){
uchar gain;
blc_channel input("/input", BLC_CHANNEL_WRITE, 'FL64', 'NDEF', 1, 2);
Row<u32> inputs(input.uints32, input.total_length, false, true);
colvec Z=linspace<colvec>(0.99999, 0.999999999999, 100);
blc_channel output("/output", BLC_CHANNEL_WRITE, 'FL64', 'NDEF', 2, Z.size(), inputs.size());
blc_channel transfert("/transfert", BLC_CHANNEL_WRITE, 'FL64', 'NDEF', 1, Z.size());
mat outputs(output.doubles, Z.size(), inputs.size(), false, true);
colvec transferts(transfert.doubles, Z.size(), false, true);
rowvec dinputs(inputs.size());
BLC_COMMAND_LOOP(us_period){
if (blc_loop_iteration!=0) blc_eprint_cursor_up(1);
......@@ -152,6 +169,10 @@ int main(int argc, char **argv){
else delay_ns = 1000000000 - previous_ns + timestamp.tv_nsec;
previous_ns=timestamp.tv_nsec;
dinputs=conv_to<dinputs>::from(inputs);
outputs+dinputs+(outputs.each_col()%Z).each_row(); // z
transferts=outputs.col(0)/outputs.col(1);
for (auto &neuron:neurons){
neuron.update();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment