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 <torch/extension.h> | |
#include <Metal/Metal.h> | |
#include <Foundation/Foundation.h> | |
#include <iostream> | |
// Define a function to add tensors using Metal | |
torch::Tensor add_tensors_metal(torch::Tensor a, torch::Tensor b, const std::string& shaderFilePath) { | |
// Check that device is MPS | |
if (a.device().type() != torch::kMPS || b.device().type() != torch::kMPS) { |
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 os | |
from setuptools import find_packages, setup | |
import torch | |
from torch.utils.cpp_extension import CppExtension, BuildExtension | |
def get_extensions(): | |
# prevent ninja from using too many resources | |
try: | |
import psutil |
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
var soln = new List<(int a, int b, int c)>(); | |
// Bound for a | |
// NOTE: this is a first guess, we'll do better later | |
// a + b + c = N => If all are equal, upper bound is N/3 | |
double aMax = n / 3.0; | |
for (int a=1; a<aMax; a++) | |
{ |
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
var soln = new List<(int a, int b, int c)>(); | |
// Bound for a | |
// NOTE: this is a first guess, we'll do better later | |
// a + b + c = N => If all are equal, upper bound is N/3 | |
double aMax = n / 3.0; | |
for (int a=1; a<aMax; a++) | |
{ |
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
// b = (N^2 - 2Na) / (2N - 2a) | |
int num = n * n - 2 * n * a; | |
int denom = 2 * n - 2 * a; | |
if (num % denom != 0) | |
{ | |
continue; | |
} | |
int b = num / denom; |
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
// Given int n | |
var soln = new List<(int a, int b, int c)>(); | |
// Bound for a | |
double aMax = (1.0 - (1.0 / Math.Sqrt(2.0))) * n; | |
for (int a=1; a<aMax; a++) | |
{ |
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
struct CircleAnimation: AnimatableModifier { | |
var angle: Float | |
var radius: Float | |
var animatableData: Float { | |
get { angle } | |
set { angle = newValue } | |
} | |
func body(content: Content) -> some View { |
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
struct CircleAnimation: AnimatableModifier { | |
var angle: Float | |
var radius: Float | |
var animatableData: Float { | |
get { angle } | |
set { angle = newValue } | |
} | |
func body(content: Content) -> some View { |
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
struct CircleWithAnimatableAngle: Shape { | |
var angle: Float | |
var radius: Float | |
var animatableData: Float { | |
get { angle } | |
set { angle = newValue } | |
} | |
func path(in rect: CGRect) -> Path { |
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
struct ContentView: View { | |
@State var angle: Float = Float.pi / 2.0 | |
let radius: Float = 200 | |
var body: some View { | |
ZStack { | |
Circle() | |
.strokeBorder(.black, lineWidth: 2) | |
.foregroundColor(.clear) |
NewerOlder