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
function convolve(x, h) | |
implicit none | |
!x is the signal array | |
!h is the noise/impulse array | |
real, dimension(:), allocatable :: convolve, y | |
real, dimension(:) :: x, h | |
integer :: kernelsize, datasize | |
integer :: i,j,k | |
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
integer function djb_hash(str) result(hash) | |
implicit none | |
character(len=*),intent(in) :: str | |
integer :: hash | |
integer :: i | |
hash = 5381 | |
do i=1,len(str) |
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
real function fmincg(length, nn_params, input_layer_size, hidden_layer_size, num_labels, inputdata, y, lambda) | |
implicit none | |
! Copyright (C) 2001 and 2002 by Carl Edward Rasmussen. Date 2002-02-13 | |
! (C) Copyright 1999, 2000 & 2001, Carl Edward Rasmussen | |
! | |
! Permission is granted for anyone to copy, use, or modify these | |
! programs and accompanying documents for purposes of research or | |
! education, provided this copyright notice is retained, and note is | |
! made of any changes that have been made. |
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
subroutine matrix_multiply(first_matrix, first_transposed, second_matrix, second_transposed, result_matrix) | |
!This subroutine multiplies two matrices using the Intel MKL xGEMM multiplication routines | |
!The routines can be a little tricky, so I've made it a little easier to use them consistently | |
!first_matrix and second_matrix are the input matrices | |
!first_transposed and second_transposed are integers indicating (with a 1 or 0) whether or not | |
!the respective matrix is transposed | |
!The resulting matrix is stored in result_matrix, but you'll have to allocate that outside the routine | |
!The sGEMM below can be changed to dGEMM for double precision without any other changes to the | |
!subroutine call. You'll then have to change the 'real' variables to 'double precision'. | |
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
class AsyncTokenBucket(object): | |
"""Implementation of an awaitable token bucket that defaults to a single token at a time. | |
Based on https://code.activestate.com/recipes/511490-implementation-of-the-token-bucket-algorithm/""" | |
def __init__(self, max_tokens, fill_rate): | |
self.max_tokens = float(max_tokens) | |
self.current_tokens = float(max_tokens) | |
self.fill_rate = float(fill_rate) | |
self.wait_time = (1.0 / self.fill_rate) | |
self.timestamp = time.time() |