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
| def VOCap(rec, prec): | |
| length = len(rec) | |
| mrec = np.zeros(length + 2) | |
| mrec[-1] = 1 | |
| mpre = np.zeros(length + 2) | |
| for i in range(length, 0, -1): | |
| mpre[i] = max(prec[i-1], mpre[i+1]) | |
| mrec[i] = rec[i - 1] | |
| mpre[0] = max(0, mpre[1]) | |
| i = np.where(mrec[1:] != mrec[:-1])[0] + 1 |
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
| #include <stdio.h> | |
| int main() | |
| { | |
| int deviceCount; | |
| cudaGetDeviceCount(&deviceCount); | |
| int device; | |
| for(device = 0; device < deviceCount; ++device) { | |
| cudaDeviceProp deviceProp; | |
| cudaGetDeviceProperties(&deviceProp, device); |
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
| /* | |
| * How to compile (assume cuda is installed at /usr/local/cuda/) | |
| * nvcc -c -I/usr/local/cuda/include svd_example.cpp | |
| * g++ -fopenmp -o a.out svd_example.o -L/usr/local/cuda/lib64 -lcudart -lcublas -lcusolver | |
| * | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> |
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
| #include <Eigen/Eigenvalues> | |
| #include <iostream> | |
| using namespace std; | |
| using namespace Eigen; | |
| void test() { | |
| MatrixXd A = MatrixXd::Random(6,6); | |
| cout << "here is a random 6*6 matrix, A:" << endl << A << endl << endl; | |
| EigenSolver<MatrixXd> es(A); |
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
| #include <Eigen/Eigenvalues> | |
| #include <iostream> | |
| using namespace std; | |
| using namespace Eigen; | |
| void test() { | |
| MatrixXd A = MatrixXd::Random(6,6); | |
| cout << "here is a random 6*6 matrix, A:" << endl << A << endl << endl; | |
| EigenSolver<MatrixXd> es(A); |
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
| Account = { | |
| balance = 0 | |
| } | |
| function Account:new(o) | |
| o = o or {} | |
| setmetatable(o, self) | |
| self.__index = self | |
| return o | |
| end |
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
| Account = { | |
| balance = 0, | |
| withdraw = function(self, v) | |
| self.balance = self.balance - v | |
| end | |
| } | |
| function Account:deposit(v) | |
| self.balance = self.balance + v | |
| end |
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
| Account = { | |
| balance = 0 | |
| } | |
| function Account:withdraw (v) | |
| self.balance = self.balance - v | |
| end | |
| Account.withdraw(Account, 100) | |
| print(Account.balance) |
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
| function getlooplen(n) | |
| local count = 1 | |
| while n ~= 1 do | |
| count = count + 1 | |
| if n % 2 == 0 then | |
| n = n / 2 | |
| else | |
| n = 3 * n + 1 | |
| end | |
| end |
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
| function require (name) | |
| if not package.loaded[name] then | |
| local loader = findloader(name) | |
| if loader == nil then | |
| error() | |
| end | |
| package.loaded[name] = true | |
| local res = loader(name) | |
| if res ~= nil then | |
| package.loaded[name] = res |
NewerOlder