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 math | |
| class SegmentTree: | |
| def __init__(self, arr, function, neutral_element): | |
| self.m = len(arr) | |
| k = math.ceil(math.log2(self.m)) + 1 | |
| self.n = 2**k | |
| self.arr = arr | |
| self.tree = [neutral_element for _ in range(self.n)] | |
| self.foo = function | |
| self.neutral_element = neutral_element |
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> | |
| #include <stdlib.h> | |
| struct Node{ | |
| struct Node *parent; | |
| struct Node *left; | |
| struct Node *right; | |
| int index; | |
| int value; | |
| }; |
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
| const std = @import("std"); | |
| const builtin = @import("builtin"); | |
| pub fn main() !void { | |
| const n = 20; | |
| var idx : [n]u8 = undefined; | |
| for (&idx, 0..) |*id, i| { | |
| id.* = @intCast(i); | |
| } |
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 wasserstein_distance_gaussian_analytical(G1, G2): | |
| mu1, sigma1 = G1 | |
| mu2, sigma2 = G2 | |
| diff_mean = mu1 - mu2 | |
| squared_diff_mean = np.dot(diff_mean, diff_mean) # euclidean norm | |
| sigma1_sqrt = linalg.sqrtm(sigma1) | |
| sigma_product = np.dot(sigma1_sqrt, np.dot(sigma2, sigma1_sqrt)) | |
| sigma_product_sqrt = scipy.linalg.sqrtm(sigma_product) |
OlderNewer