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
/* gcc -Wall -std=c99 plplotline3.c -o plplotline3 -lplplotd */ | |
#include <stddef.h> | |
#include <plplot/plplot.h> | |
int main(void) | |
{ | |
const size_t num_atoms = 10; | |
const double positions[][3] = {{ 13.935, 18.529, 29.843 }, { 13.088, 19.661, 26.283 }, { 12.726, 17.033, 23.612 }, { 12.179, 17.659, 19.887 }, { 10.253, 15.79, 17.221 }, { 11.082, 16.103, 13.475 }, { 8.009, 15.163, 11.389 }, { 8.628, 13.975, 7.913 }, { 5.213, 12.642, 6.966 }, { 3.589, 12.601, 3.497 }}; |
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
/** | |
* @file bitset.c | |
* @brief Implementation of a bit set data structure. | |
*/ | |
#include <stdlib.h> | |
#include <assert.h> | |
#include "bitset.h" |
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 <stdio.h> | |
#include <stddef.h> | |
#include <gsl/gsl_matrix.h> | |
int print_matrix(FILE *f, const gsl_matrix *m) | |
{ | |
int status, n = 0; | |
for (size_t i = 0; i < m->size1; i++) { | |
for (size_t j = 0; j < m->size2; j++) { |
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 <gsl/gsl_vector.h> | |
#include <gsl/gsl_blas.h> | |
void cross_product(const gsl_vector *u, const gsl_vector *v, gsl_vector *product) | |
{ | |
double p1 = gsl_vector_get(u, 1)*gsl_vector_get(v, 2) | |
- gsl_vector_get(u, 2)*gsl_vector_get(v, 1); | |
double p2 = gsl_vector_get(u, 2)*gsl_vector_get(v, 0) | |
- gsl_vector_get(u, 0)*gsl_vector_get(v, 2); |
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
/* | |
Compile with: | |
gcc -Wall -std=c99 test_stack_allocation_of_vectors.c -o test_stack_allocation_of_vectors `gsl-config --libs` | |
*/ | |
#include <stdio.h> | |
#include <stddef.h> | |
#include <string.h> | |
#include <assert.h> |
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 <cstdlib> | |
#include <vector> | |
#include <iostream> | |
#include <ESBTL/default.h> | |
#include <ESBTL/selected_atom_iterator.h> | |
#include <ESBTL/atom_selectors.h> | |
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
template <typename T = double> | |
vector<T> linspace(T a, T b, size_t N) { | |
T h = (b - a) / static_cast<T>(N-1); | |
vector<T> xs(N); | |
typename vector<T>::iterator x; | |
T val; | |
for (x = xs.begin(), val = a; x != xs.end(); ++x, val += h) | |
*x = val; | |
return xs; | |
} |
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 <cmath> | |
inline unsigned next_power_of_two(unsigned x) { | |
return unsigned(exp2f(ceilf(log2f(float(x))))); | |
} |
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
#define abort_unless(expr) do { \ | |
if (!(expr)) { \ | |
fprintf(stderr, "%s:%u (%s): Assertion `%s' failed.\n", \ | |
__FILE__, __LINE__, __func__, __STRING(expr)); \ | |
fflush(stderr); \ | |
abort(); \ | |
} \ | |
} while (0) |
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
#ifndef DOUBLE2_H | |
#define DOUBLE2_H | |
#include <cmath> | |
#include <ostream> | |
#include <initializer_list> | |
struct double2 { | |
union { |
OlderNewer