Skip to content

Instantly share code, notes, and snippets.

@oxyflour
oxyflour / BiCGSTAB.py
Created February 29, 2024 14:37 — forked from bridgesign/BiCGSTAB.py
BiCGSTAB or BCGSTAB Pytorch implementation GPU support
import torch
import warnings
class BiCGSTAB():
"""
This is a pytorch implementation of BiCGSTAB or BCGSTAB, a stable version
of the CGD method, published first by Van Der Vrost.
For solving ``Ax = b`` system.
@oxyflour
oxyflour / add-mesh.py
Created February 3, 2024 08:02
blender scripts
# %%
import bpy
# make mesh
vertices = [(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)]
edges = []
faces = [(0, 1, 2), (1, 2, 3), (2, 3, 1), (3, 1, 0)]
new_mesh = bpy.data.meshes.new('new_mesh')
new_mesh.from_pydata(vertices, edges, faces)
new_mesh.update()
@oxyflour
oxyflour / main.py
Last active February 4, 2024 13:04
import occ, mesh, utils
verts, faces, grps = mesh.from_stp('models/cylinder.stp')
from pytorch3d import ops, structures, loss as loss3d
from torch import Tensor, optim
V, F = Tensor(verts).to('cuda'), Tensor(faces).long().to('cuda')
G = { 'Cylinder': [], 'Plane': [] }
for typ, face in grps:
if not typ in G:
G[typ] = []
@oxyflour
oxyflour / main.cc
Created September 3, 2023 04:27
segment boolean
#include <vector>
using namespace std;
struct segment_t {
int shape;
double lower, upper;
};
inline auto operator<(const segment_t &a, const segment_t &b) {
@oxyflour
oxyflour / main.py
Last active September 3, 2023 04:25
cst + gp
import os
import tempfile
import numpy as np
import math
from skopt import gp_minimize
exe = r"D:\Program Files (x86)\CST STUDIO SUITE 2019\AMD64\CST DESIGN ENVIRONMENT_AMD64.exe"
cst = r"C:\Users\oxyfl\Downloads\三频.cst"
ret_tree_path = '1D Results\S-Parameters\S1,1'
@oxyflour
oxyflour / main.py
Last active May 3, 2023 12:47
80x accel for scikit-rf with pytorch
from typing import List, Tuple
from skrf import Network, Circuit, DefinedGammaZ0
from time import perf_counter
import numpy as np
import torch
n = Network('test/touchstone/dipole-x2.s2p')
f = n.frequency
z = DefinedGammaZ0(f, 50)
@oxyflour
oxyflour / x.bash
Created October 3, 2022 04:31
openvpn settings
# https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-16-04
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf && systctl -p
@oxyflour
oxyflour / index.ts
Last active June 12, 2021 13:12
slicing of polygon
interface Point {
x: number
y: number
}
type Ring = Point[]
interface Joint {
i: number
j: number
k: number
p: Point
@oxyflour
oxyflour / index.ts
Last active September 29, 2022 15:25
ipfs pubsub webrtc star
import ipfs from 'ipfs'
function $e<K extends keyof HTMLElementTagNameMap>(tag: K, props = { } as { [key: string]: any }, children = [] as any[]) {
const e = document.createElement(tag)
for (const [key, val] of Object.entries(props)) {
(e as any)[key] = val
}
for (const [key, val] of Object.entries(props.style || { })) {
(e.style as any)[key] = val
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>cannon.js - container demo</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
</head>
<body>
<script type="module">