This file contains hidden or 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
/** | |
* Definition for an interval. | |
* struct Interval { | |
* int start; | |
* int end; | |
* Interval() : start(0), end(0) {} | |
* Interval(int s, int e) : start(s), end(e) {} | |
* }; | |
*/ | |
bool start_compare(Interval &a, Interval &b) { return a.start > b.start; } |
This file contains hidden or 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 ( | |
"sync" | |
) | |
func MultiMergeSortWithSem(data []float64, sem chan struct{}) []float64 { | |
if len(data) < 2 { | |
return data | |
} | |
middle := len(data) / 2 |
This file contains hidden or 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
func MultiMergeSort(data []float64, res chan []float64) { | |
if len(data) < 2 { | |
res <- data | |
return | |
} | |
leftChan := make(chan []float64) | |
rightChan := make(chan []float64) | |
middle := len(data) / 2 |
This file contains hidden or 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
func SingleMergeSort(data []float64) []float64 { | |
if len(data) < 2 { | |
return data | |
} | |
middle := len(data) / 2 | |
return Merge(SingleMergeSort(data[:middle]), SingleMergeSort(data[middle:])) | |
} |
This file contains hidden or 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
func Merge(ldata []float64, rdata []float64) (result []float64) { | |
result = make([]float64, len(ldata)+len(rdata)) | |
lidx, ridx := 0, 0 | |
for i := 0; i < cap(result); i++ { | |
switch { | |
case lidx >= len(ldata): | |
result[i] = rdata[ridx] | |
ridx++ | |
case ridx >= len(rdata): |
This file contains hidden or 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 | |
import time | |
import sys | |
import csv | |
import mmap | |
ret = [] | |
current_time = time.time() | |
with open(sys.argv[1], 'r') as f: |
This file contains hidden or 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 | |
import sys | |
np.random.seed(0) | |
size = int(sys.argv[1]) if len(sys.argv) > 1 else 4096*4096 | |
outfile = open('ascii_uint32_vec_{}.txt'.format(size), 'w') | |
A = np.random.randint(4294967295, size=(1, size)) | |
np.savetxt(outfile, A) | |
np.save('validation_uint32_vec_{}'.format(size), A) | |
outfile.close() |
This file contains hidden or 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 | |
import sys | |
np.random.seed(0) | |
size = int(sys.argv[1]) if len(sys.argv) > 1 else 4096 | |
outfile = open('ascii_floats_{}.txt'.format(size), 'w') | |
A = np.random.random((size, size)) | |
np.savetxt(outfile, A) | |
np.save('validation_floats_{}'.format(size), A) | |
outfile.close() |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"strings" | |
"os" | |
"bufio" | |
"io" | |
"strconv" | |
"gonum.org/v1/gonum/mat" |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"strings" | |
"os" | |
"bufio" | |
"io" | |
"strconv" | |
"encoding/binary" |