Skip to content

Instantly share code, notes, and snippets.

int testfgets(char *fastqFile) {
clock_t start, end;
double cpu_time_used;
char *line = malloc(sizeof(char) * MAXLINELEN);
start = clock();
FILE *ptr;
if ((ptr = fopen(fastqFile, "r")) == NULL) {
printf("no such file as %s \n", fastqFile);
return 0;
#define C_SHIFT 1 //01
#define G_SHIFT 2 //10
#define T_SHIFT 3 //11
/**
*
* @param readString: The DNA sequence to be encoded
* @param stringLength : The number of characters in the DNA sequence
* @return uint8_t type array of bits
*/
uint8_t *bitEncode(char *readString, int stringLength) {
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define n 2048
double A[n][n];
double B[n][n];
double C[n][n];
import java.util.Random;
public class MatrixMultiplication {
static int n = 2048;
static double[][] A = new double[n][n];
static double[][] B = new double[n][n];
static double[][] C = new double[n][n];
public static void main(String[] args) {
//populate the matrices with random values between 0.0 and 1.0
import random
import time
n = 2048
#populate the matrices with random values between 0.0 and 1.0
A = [[random.random() for row in range(n)] for col in range(n)]
B = [[random.random() for row in range(n)] for col in range(n)]
C = [[0 for row in range(n)] for col in range(n)]
//courtesy of MIT Open Courseware (https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-172-performance-engineering-of-software-systems-fall-2018/lecture-slides/MIT6_172F18_lec2.pdf)
#include <math.h>
void orrery (){
const double radius = 6371000.0;
const double diameter = 2 * radius;
const double circumference = M_PI * diameter;
const double cross_area = M_PI * radius * radius;
const double surface_area = circumference * diameter;
}
//courtesy: MIT Open Courseware (https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-172-performance-engineering-of-software-systems-fall-2018/lecture-slides/MIT6_172F18_lec2.pdf)
#include <stdbool.h>
#include <math.h>
typedef struct{
double x; //x-coordinate
double y; //y-coordinate
double z; //z-coordinate
double r; // radius of the ball
} ball_t;
//courtesy: MIT Open Courseware (https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-172-performance-engineering-of-software-systems-fall-2018/lecture-slides/MIT6_172F18_lec2.pdf)
#include <stdbool.h>
#include <math.h>
typedef struct{
double x; //x-coordinate
double y; //y-coordinate
double z; //z-coordinate
double r; // radius of the ball
} ball_t;
void full_adder(int a, int b, int c, int *sum, int *carry) {
if (a == 0) {
if (b == 0) {
if (c == 0) {
*carry = 0;
*sum = 0;
} else {
*carry = 0;
*sum = 1;
}
void full_adder(int a, int b, int c, int *sum, int *carry) {
int test = ((a == 1) << 2 | (b == 1) << 1 | (c == 1));
switch (test) {
case 0:
*carry = 0;
*sum = 0;
break;
case 1:
*carry = 0;