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 pickle | |
import time | |
import cvxpy as cp | |
from cvxpy.lin_ops.lin_utils import ID_COUNTER | |
# format seconds as hh:mm:ss.sss (approx. ISO 8601 format) | |
def hhmmss(secs) -> str: | |
return f"{secs // 3600:02.0f}:{secs // 60:02.0f}:{secs % 60:0.1f}" |
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 _arrayToHeap(typedArray){ | |
var numBytes = typedArray.length * typedArray.BYTES_PER_ELEMENT; | |
var ptr = Module._malloc(numBytes); | |
var ptr_i32 = ptr >> 2; // divide byte offset by 4 to account for 4-byte int pointer | |
var heapBytes = Module.HEAP32.subarray(ptr_i32, ptr_i32 + typedArray.length); | |
heapBytes.set(typedArray); | |
return heapBytes; | |
} |
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 <vector> | |
#include <string> | |
#include <iostream> | |
#include "optional.hpp" | |
using nonstd::optional; | |
class prove_same_size | |
{ | |
public: |
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 <string> | |
#include <iostream> | |
#include "optional.hpp" | |
using nonstd::optional; // this is like Maybe. For more complex examples could use variant (discriminated union) | |
class proved_non_zero_maybe | |
{ | |
public: | |
static optional<proved_non_zero_maybe> prove(int v) |