repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
ernestyalumni/CompPhys | moreCUDA/samples02/texdynamics/commonlib/texObjCls2d.h | <gh_stars>10-100
/* texObjCls2d.h
* texture memory Object class, 2-dim.
* <NAME> <EMAIL>
* 20161116
*
* cf. https://devblogs.nvidia.com/parallelforall/cuda-pro-tip-kepler-texture-objects-improve-performance-and-flexibility/
* M. Clark, CUDA Pro Tip: Kepler Texture Objects Improve Performance and Flexibility
*... |
ernestyalumni/CompPhys | Cpp/math/Rings/Ring.h | //------------------------------------------------------------------------------
/// \file Ring.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Ring.
/// \ref Ch. 21 Class Hierarchies, 21.2.Design of Class Hierarchies
/// The C++ Programming Language, 4th Ed., Stroustrup;
/// \details Ring, following interface i... |
ernestyalumni/CompPhys | CFitz/printfact1.c | /* printfact1.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.9 Functions
Programming note from Fitzpatrick. pp.50
"Ideally, function definitions should always precede the corresponding function
calls in a C program.
Unfortunately, for the sake of logical clarity, most C programmers prefer to p... |
ernestyalumni/CompPhys | MonteCarlo/RandomNumberGenerators/RandomNumberGenerators.h | <gh_stars>10-100
//------------------------------------------------------------------------------
/// \file RandomNumberGenerators.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Random number generators (RNG).
/// \url https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Programs/LecturePrograms/pr... |
ernestyalumni/CompPhys | Cpp/Ising/IsingGPU/common/gridsetup.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/**
* @file : gridsetup.h
* @brief : Utility functions to set up (thread) grid on device GPU
* @details : Utility functions to set up (thread) grid on device GPU
*
* @author : <NAME> <<EMAIL>>
* @date : 20170110
* @ref : https://devblogs.nvidia... |
ernestyalumni/CompPhys | moreCUDA/Utilities/ErrorHandling.h | <reponame>ernestyalumni/CompPhys<filename>moreCUDA/Utilities/ErrorHandling.h
//------------------------------------------------------------------------------
/// \file ErrorHandling.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Error Handling functions.
/// \url https://docs.nvidia.com/cuda/cuda-runtime-api/
///... |
ernestyalumni/CompPhys | CFitz/randomEY.c | /* randomEY.c */
/*
Program to test operation of rand() function
I took random.c and made changes to play around it
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define N_MAX 10000000
// Function prototypes
int randommeanvar(int);
int main()
{
int i, seed;
double sum_0, sum_1, mean, var, x;
... |
ernestyalumni/CompPhys | moreCUDA/cudaforengineers/dd_1d_global/dd_1d_global.h | /* dd_1d_global.h
* 1-dimensional double derivative (dd for '') by finite difference with global memory
* <NAME> <EMAIL>
* 20160625
*/
#ifndef __DD_1D_GLOBAL_H__
#define __DD_1D_GLOBAL_H__
void ddParallel(float *out, const float *in, int n, float h);
#endif
|
ernestyalumni/CompPhys | moreCUDA/heat3d/physlib/R3grid.h | /* R3grid.h
* R3 under discretization (discretize functor) to a grid
* <NAME> <EMAIL>
* 20160701
*/
#ifndef __R3GRID_H__
#define __R3GRID_H__
#include <array> // std::array
#include <cmath> // expf
class Grid3d
{
public :
std::array<int,3> Ld;
std::array<float,3> ld;
std::array<float,3> hd;
float* t... |
ernestyalumni/CompPhys | CFitz/printfact5.c | /* printfact5.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
Arrays
*/
/*
Program to print factorials of all integers
between 0 and 20
*/
#include <stdio.h>
/* Function prototype for factorial() */
void factorial(double []);
int main()
{
int j;
double fact[21]; // Declaration of arra... |
ernestyalumni/CompPhys | moreCUDA/cudaforengineers/heat_2d/interactions.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/* interactions.h
* 2-dim. Laplace eq. (heat eq.) by finite difference with shared memory
* <NAME> <EMAIL>
* 20160626
*/
#ifndef __INTERACTIONS_H__
#define __INTERACTIONS_H__
#include "heat_2d.h"
#include <stdio.h>
#include <stdlib.h>
// Fedora 23 Workstation
#defin... |
ernestyalumni/CompPhys | Cpp/progs/ch05/integrate1d.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/*
* cf. <NAME>, Computational Physics, University of Oslo (2015)
* http://www.mn.uio.no/fysikk/english/people/aca/mhjensen/
* <NAME> (I typed it up and made modifications)
* <EMAIL>
* MIT License
* cf. Chapter 5 Numerical Integration
* 5.1 Newton-Cotes Quadrat... |
ernestyalumni/CompPhys | CFitz/passfunction.c | <reponame>ernestyalumni/CompPhys
/* passfunction.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.10 Pointers
*/
/*
Program to illustrate the passing of function names as
arguments to other functions via pointers
*/
#include <stdio.h>
/* Function prototype for host fun. */
void cube(double (*)(doubl... |
ernestyalumni/CompPhys | MonteCarlo/Integrate1.h | //------------------------------------------------------------------------------
/// \file RandomNumberGenerators.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Random number generators (RNG).
/// \url https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Programs/LecturePrograms/programs/MCIntro/cp... |
ernestyalumni/CompPhys | Cpp/math/03-gcd/gcd.h | <filename>Cpp/math/03-gcd/gcd.h
/**
* @file gcd.h
* @brief Calculate the greatest common divisor of 2 integers.
* @ref <NAME>. C++ for Mathematicians: An Introduction for Students and Professionals. 2006. Ch. 3.
* Progra 3.1: The header file gcd.h
* @details Note: gcd(0,0) will return 0 and print an ... |
ernestyalumni/CompPhys | Cpp/math/03-gcd/gcd-extended/gcd.h | <filename>Cpp/math/03-gcd/gcd-extended/gcd.h
/**
* @file gcd.h
* @brief Calculate the greatest common divisor of 2 integers.
* @ref <NAME>. C++ for Mathematicians: An Introduction for Students and Professionals. 2006. Ch. 3.
* Program 3.1: The header file gcd.h
* @details Note: gcd(0,0) will return 0... |
ernestyalumni/CompPhys | CFitz/ftoc.c | <filename>CFitz/ftoc.c
/* ftoc.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.15 Command Line Parameters pp. 78
EY suffix means, this is my own changes, to explore what char *argv[] means
"
The main() function may optionally possess special arguments which allow parameters
to be passed to this ... |
ernestyalumni/CompPhys | Cpp/Ising/IsingGPU/drafts/IsingGPU/grid2d/grid2d.h | <gh_stars>10-100
/**
* @file : grid2d.h
* @brief : 2-dim. grid with spins "sitting" or "living" on top of it, header file, in CUDA C++11/14,
* @details : struct with smart ptrs, unique ptrs
*
* @author : <NAME> <<EMAIL>>
* @date : 20171231
* @ref : M. Hjorth-Jensen, Computational Physics, Universit... |
ernestyalumni/CompPhys | MonteCarlo/ParticlesInABox.h | <gh_stars>10-100
//------------------------------------------------------------------------------
/// \file ParticleInABox.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Particles in a box.
/// \url
/// \ref
/// \details Particles in a box.
/// There is public inheritance of the interface (interface inheritance),... |
ernestyalumni/CompPhys | CFitz/multifile/factorial.c | /* factorial.c */
/*
Function to evaluate factorial (in floating point form)
of non-negative integer j. Result stored in variable fact.
global variable definitions in the file factorial.c
Compiling note:
gcc main.c factorial.c
and it worked
*/
#include <stdio.h>
#include <stdlib.h>
/* Global variable ... |
ernestyalumni/CompPhys | moreCUDA/heat3d/physlib/heat_3d.h | <gh_stars>10-100
/* heat_3d.h
* 3-dim. Laplace eq. (heat eq.) by finite difference with shared memory
* <NAME> <EMAIL>
* 20160729
*/
#ifndef __HEAT_3D_H__
#define __HEAT_3D_H__
#include "../commonlib/finitediff.h"
#include "dev_R3grid.h"
extern __constant__ float dev_Deltat[1]; // Deltat
extern __constant__ flo... |
ernestyalumni/CompPhys | moreCUDA/LatticeBoltzmannmethod/LatticeBoltzmann2D_gfx/commonlib/checkerror.h | <gh_stars>10-100
/*
* checkerror.h
*
* EXAMPLE of USAGE:
* checkCudaErrors( CUDA commandyouwanttocheckerrorsfor ) ;
*
* */
#ifndef __ERRORS_H__
#define __ERRORS_H__
#include <iostream> // std::cerr, std::endl;
#include <cuda.h>
#include <cuda_runtime.h> // cudaSuccess
#include <cuda_runtime_api.h>
#define che... |
ernestyalumni/CompPhys | MonteCarlo/TimeEvolutionStateTransitions/Simulation.h | //------------------------------------------------------------------------------
/// \file Simulation.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Do the actual Monte Carlo routine.
/// \url https://en.wikipedia.org/wiki/Monte_Carlo_method
/// \ref CompPhys.pdf
/// \details A Monte Carlo simulation uses repeate... |
ernestyalumni/CompPhys | CFitz/factorial.c | /* factorial.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.8 Control Statements
*/
/*
Program to evaluate factorial of non-negative
integer n supplied by user.
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, count;
double fact = 1.;
/* Read in value of n */
printf("\nn = ");
... |
ernestyalumni/CompPhys | CFitz/multifile/main.c | /* main.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.14 Multi-file
global variable declarations in the file main.c
Compiling note:
gcc main.c factorial.c
and it worked
*/
/*
Program to print factorials of all integers
between 0 and 20
*/
#include <stdio.h>
/* Prototype for function facto... |
ernestyalumni/CompPhys | moreCUDA/thruststuff/ranges/ranges/ranges.h | /**
* ranges.h
*
* \file ranges.h
* \author <NAME>
* \brief various ranges (for thrust), including repeated_range
*
* typed up by <NAME> <EMAIL>
* \date 20170103
* cf. https://github.com/thrust/thrust/blob/master/examples/repeated_range.cu
*
*
* Compilation tip
* nvcc -std=c++11 repeated_range.cu -o ... |
ernestyalumni/CompPhys | CFitz/iteration.c | /* iteration.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.8 Control Statements
EY : 20160517 Compiling note:
cf. http://stackoverflow.com/questions/5248919/c-undefined-reference-to-sqrt-or-other-mathematical-functions
Answer from paxdiablo
"You may find that you have to link with the math libra... |
ernestyalumni/CompPhys | Rings/Function.h | <reponame>ernestyalumni/CompPhys
//------------------------------------------------------------------------------
/// \file Function.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Implementing (mathematical) functions.
/// \url
/// \ref Ch. 21 Class Hierarchies, 21.2.Design of Class Hierarchies
/// The C++ Prog... |
ernestyalumni/CompPhys | CFitz/expressions.c | <gh_stars>10-100
/* expressions.c
Fitzpatrick. Computational Physics. 329.pdf
2.3 Expressions and Statements
*/
#include <stdio.h>
#include <math.h>
int a = 3, b = 5;
double factor = 1.2E-5;
// symbolic constant is a name that substitutes for a sequence of characters
#define PI 3.141593
int k;
double x,y;
... |
ernestyalumni/CompPhys | moreCUDA/CURAND/CuRand/InitialStates.h | //------------------------------------------------------------------------------
/// \file InitialStates.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Initial states for pseudorandom numbers..
/// \url https://docs.nvidia.com/cuda/curand/device-api-overview.html
/// \ref
/// \details Setup the initial states, w... |
ernestyalumni/CompPhys | Cpp/math/Fields/factor.h | <gh_stars>10-100
/**
* @file : factor.h
* @author : <NAME>
* @email : <EMAIL>
* @brief : Header file for factor procedure
* @ref : pp. 73 Program 5.1 Ch. 5 Arrays; <NAME>, C++ for Mathematicians: An Introduction for Students and Professionals. Taylor & Francis Group, 2006.
*
* If you find this code usef... |
ernestyalumni/CompPhys | moreCUDA/constant/structs/constant_structs.h | <filename>moreCUDA/constant/structs/constant_structs.h
/**
* @file : constant_structs.h
* @brief : Examples of using constant memory for CUDA, with smart pointers, in header file
* @details : constant memory for CUDA examples
*
* @author : <NAME> <<EMAIL>>
* @date : 20170103
* @ref : http://doc... |
ernestyalumni/CompPhys | Cpp/Ising/Ising/grid2d/grid2d.h | /**
* @file : grid2d.h
* @brief : 2-dim. grid with spins "sitting" or "living" on top of it, header file, in C++11/14,
* @details : struct with smart ptrs, unique ptrs
*
* @author : <NAME> <<EMAIL>>
* @date : 20171229
* @ref : <NAME>, Computational Physics, University of Oslo (2015)
*
* https://... |
ernestyalumni/CompPhys | Cpp/math/Fields/ComplexNumber.h | //------------------------------------------------------------------------------
/// \file : ComplexNumber.h
/// \author : <NAME>
/// \email : <EMAIL>
/// \brief : ComplexNumber numbers as Concrete class or Arithmetic type, parametrized
/// \ref : 3.2.1.1 An Arithmetic Type, Ch. 3 A Tour of C++: Abstraction
//... |
ernestyalumni/CompPhys | moreCUDA/scan/methods/scans.h | /* scans.h
* <NAME>
* <EMAIL>
* Demonstrates Hillis/Steele and Blelloch (exclusive) scan with a parallel implementation
* with CUDA C/C++ and global memory
*
* */
#ifndef __SCANS_H__
#define __SCANS_H__
#include <vector>
#include "checkerror.h" // checkCudaErrors
// parallel implementations
__global__ void Bl... |
ernestyalumni/CompPhys | moreCUDA/heat_2d_refactor/commonlib/tex_anim2d.h | <reponame>ernestyalumni/CompPhys<filename>moreCUDA/heat_2d_refactor/commonlib/tex_anim2d.h
/* tex_anim2d.h
* 2-dim. GPU texture animation
* <NAME> <EMAIL>
* 20160720
*/
#ifndef __TEX_ANIM2D_H__
#define __TEX_ANIM2D_H__
#include "../physlib/heat_2d.h" // BC
#include <stdio.h>
#define GL_GLEXT_PROTOTYPES // need... |
ernestyalumni/CompPhys | Cpp/Ising/IsingGPU/drafts/IsingGPU/dynam/metropolis.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/**
* @file : metropolis.h
* @brief : Metropolis algorithm for 2-dim. grid, with initialization, header file, in CUDA C++11/14,
* @details : initialize function, metropolis function
*
* @author : <NAME> <<EMAIL>>
* @date : 20170110
* @ref : M. Hjorth... |
ernestyalumni/CompPhys | moreCUDA/samples02/physlib/dev_R2grid.h | <filename>moreCUDA/samples02/physlib/dev_R2grid.h
/* dev_R2grid.h
* R2 under discretization (discretize functor) to a thread block
* <NAME> <EMAIL>
* 20161114
*
* compilation tip: (compile separately)
* nvcc -std=c++11 -c ./physlib/dev_R2grid.cu -o dev_R2grid.o
*
*/
#ifndef __DEV_R2GRID_H__
#define __DEV_R2G... |
ernestyalumni/CompPhys | Cpp/math/AffineSpace/Point.h | //------------------------------------------------------------------------------
/// \file Point.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Program 6.1: Header file Point.h for the Point class
/// \ref pp. 95. <NAME>. C++ for Mathematicians: An Introduction
/// for Students and Professionals. 2006. Ch. 6... |
ernestyalumni/CompPhys | gslExamples/SO3.c | /* SO3.c */
// SO(3) Lie group implemented with GNU GSL
// cf. wikipedia, "Rotation_group_SO(3)#Infinitesimal_rotations"
// EY note : 20160519 Bizarrely, matrix multiplication isn't implemented in a straightforward manner with the gsl_matrix class; see blas (which I don't know what it is yet) and dgemm for the librar... |
ernestyalumni/CompPhys | Cpp/math/12-polynomials/original/mycomplex_revised.h | //------------------------------------------------------------------------------
/// \file mycomplex_revised.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Program 12.3. A revised version of mycomplex that allows real and
/// imaginary parts of different types.
/// \details The basic mechanisms for defining and... |
ernestyalumni/CompPhys | Cpp/math/05-Totient/SieveOfEratosthenes/sieve.h | //------------------------------------------------------------------------------
/// \file : sieve.h
/// \author : <NAME>
/// \email : <EMAIL>
/// \brief : The header file for a procedure to build a table of primes via
/// the Sieve of Eratosthenes.
/// \ref : pp. 79 Program 5.6 Ch. 5 Arrays; <NAME>, C++ for
... |
ernestyalumni/CompPhys | moreCUDA/LatticeBoltzmannmethod/LatticeBoltzmann2D/physlib/dev_R2grid.h | /* dev_R2grid.h
* R2 under discretization (discretize functor) to a (staggered) grid
* <NAME> <EMAIL>
* 20161114
*
* compilation tip: (compile separately)
* nvcc -std=c++11 -c ./physlib/dev_R2grid.cu -o dev_R2grid.o
*
*/
#ifndef __DEV_R2GRID_H__
#define __DEV_R2GRID_H__
#include "../commonlib/checkerror.h"... |
ernestyalumni/CompPhys | Cpp/Ising/Ising/dynam/metropolis.h | <gh_stars>10-100
/**
* @file : metropolis.h
* @brief : Metropolis algorithm for 2-dim. grid, with initialization, header file, in C++11/14,
* @details : initialize function, ran1, metropolis function
*
* @author : <NAME> <<EMAIL>>
* @date : 20171229
* @ref : <NAME>, Computational Physics, Universit... |
ernestyalumni/CompPhys | moreCUDA/CUDACpp14/smartptr/smartptr.h | /**
* @file : smartptr.h
* @brief : Smart pointers header file in CUDA C++14,
* @author : <NAME> <<EMAIL>>
* @date : 20171007
* @ref :
*
* If you find this code useful, feel free to donate directly and easily at this direct PayPal link:
*
* https://www.paypal.com/cgi-bin/webscr?cmd=_donations&b... |
ernestyalumni/CompPhys | CUDA-By-Example/helloworld.c | /*
* helloworld.cu
*
* Created on: May 23, 2016
* Author: topolo
*/
/* cf. <NAME>, <NAME>. CUDA by Example: An Introduction to General-Purpose GPU Programming */
/* 3.2 A First Program */
#include <stdio.h>
int main(void) {
printf("Hello World!\n");
return 0;
}
|
ernestyalumni/CompPhys | CFitz/average.c | <filename>CFitz/average.c<gh_stars>10-100
/* average.c */
/*
Program to calculate the average of n numbers and then
compute the deviation of each number from the average
Code adapted from "Programming with C", 2nd Edition, <NAME>,
Schaum's Outline Series, (McGraw-Hill, New York NY, 1996)
*/
#include <st... |
ernestyalumni/CompPhys | moreCUDA/samples02/surfdynamics/commonlib/surfObj2d.h | <reponame>ernestyalumni/CompPhys<filename>moreCUDA/samples02/surfdynamics/commonlib/surfObj2d.h
/* surfObj2d.h
* surface memory Object class, 2-dim.
* <NAME> <EMAIL>
* 20161116
*
* cf. http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#surface-object-api
* 3.2.11.2.1. Surface Object API
*
* com... |
ernestyalumni/CompPhys | Cpp/Cpp14/Strou/structunionenum_08/structs/structs.h | <reponame>ernestyalumni/CompPhys<filename>Cpp/Cpp14/Strou/structunionenum_08/structs/structs.h
/**
* @file : structs.h
* @brief : structs in header file, in C++14,
* @details : struct
*
* @author : <NAME> <<EMAIL>>
* @date : 20171227
* @ref : Ch. 8 Structures, Unions, and Enumerations; Bjarne Strou... |
ernestyalumni/CompPhys | Cpp/Ising/IsingGPU/boundary/boundary.h | <filename>Cpp/Ising/IsingGPU/boundary/boundary.h<gh_stars>10-100
/**
* @file : boundary.h
* @brief : boundary conditions for 2-dim. Ising model as inline function
* @details : Choose correct grid index with periodic boundary conditions
*
* @author : <NAME> <<EMAIL>>
* @date : 20170112
* @ref : ht... |
ernestyalumni/CompPhys | CFitz/dataio.c | /* dataio.c
Fitzpatrick. Computational Physics. 329.pdf
2.6 Data Input and Output
*/
#include <stdio.h>
int k = 3;
double x = 5.4, y = -9.81;
// When working with a data file, 1st step is to establish buffer area,
// where information is temporarily stored whilst being transferred between
// program and file... |
ernestyalumni/CompPhys | CFitz/repeat.c | <gh_stars>10-100
/* repeat.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.15 Command Line Parameters pp. 77
"
The main() function may optionally possess special arguments which allow parameters
to be passed to this function from the operating system. There are 2 such arguments,
convetionally ca... |
ernestyalumni/CompPhys | MonteCarlo/RadioactiveDecays.h | <filename>MonteCarlo/RadioactiveDecays.h
//------------------------------------------------------------------------------
/// \file RadioactiveDecays.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Radioactive decay, modeling first-order differential equations with
/// Monte Carlo methods.
/// \url
/// \ref 11.1.4... |
ernestyalumni/CompPhys | moreCUDA/heat3d/physlib/dev_R3grid.h | /* dev_R3grid.h
* R2 under discretization (discretize functor) to a thread block
* <NAME> <EMAIL>
* 20160728
*/
#ifndef __DEV_R3GRID_H__
#define __DEV_R3GRID_H__
#include "../commonlib/errors.h"
extern __constant__ int dev_Ld[3]; // L^{d=2} = (L_x,L_y) \in \mathbb{N}^2
class dev_Grid3d
{
public:
dim3 Ld;
... |
ernestyalumni/CompPhys | gslExamples/matrixio.c | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/* matrixio.c */
// 8.4.13 Example programs for matrices of gsl-ref.pdf
// GNU GSL GNU Scientific Library reference book
// pp. 99,100
/*
Compiling advice:
gcc matrixio.c -lgsl -lgslcblas
*/
#include <stdio.h>
#include <gsl/gsl_matrix.h>
int main (void) {
int... |
ernestyalumni/CompPhys | Cpp/Ising/Ising/grid2d/sysparam.h | <gh_stars>10-100
/**
* @file : sysparam.h
* @brief : Physical parameters of the system header file, in C++11/14,
* @details : as a struct, have total energy E, total magnetization M, temperature of entire system T (in energy units)
*
* @author : <NAME> <<EMAIL>>
* @date : 20171229
* @ref : <NAME>... |
ernestyalumni/CompPhys | CFitz/printfact3.c | /* printfact3.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.10 Pointers
*/
/*
Program to print factorials of all integers
between 0 and 20
*/
#include <stdio.h>
#include <stdlib.h>
/* Prototype for function factorial() */
void factorial(int, double *);
int main()
{
int j;
double fact;
/*... |
ernestyalumni/CompPhys | Cpp/math/05-Totient/original/sieve.h | //------------------------------------------------------------------------------
/// \file : sieve.h
/// \author : <NAME>
/// \email : <EMAIL>
/// \brief : The header file for a procedure to build a table of primes via
/// the Sieve of Eratosthenes.
/// \ref : pp. 79 Program 5.6 Ch. 5 Arrays; <NAME>, C++ for
... |
ernestyalumni/CompPhys | moreCUDA/CUDACpp14/smartptr/smartCUB.h | /**
* @file : smartCUB.h
* @brief : Smart pointers for CUB header file in CUDA C++14,
* @author : <NAME> <<EMAIL>>
* @date : 20171007
* @ref :
*
* If you find this code useful, feel free to donate directly and easily at this direct PayPal link:
*
* https://www.paypal.com/cgi-bin/webscr?cmd=_don... |
ernestyalumni/CompPhys | CFitz/addmatrix_gsl.c | /* addmatrix_gsl.c */
/*
Program to add two variable dimension matrices input by user
*/
// https://www.gnu.org/software/gsl/manual/html_node/Example-programs-for-matrices.html
#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_matrix.h>
int main (void)
{
int i, j;
gsl_matrix * m = gsl_matrix_alloc(10, 3)... |
ernestyalumni/CompPhys | moreCUDA/common/gpu_bitmap.h | /*
* gpu_bitmap_draft.h
* make OpenGL bitmaps on the GPU
* <NAME> <EMAIL>
* 20160616
* */
#ifndef __GPU_BITMAP_H__
#define __GPU_BITMAP_H__
#define GL_GLEXT_PROTOTYPES /* needed for identifiers glBindBuffer,
* glDeleteBuffer, glGenBuffers, glBufferData */
#include "GL/glut.h"
#include "cuda.h"
#include "... |
ernestyalumni/CompPhys | CFitz/pointer.c | <filename>CFitz/pointer.c
/* pointer.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
Programming note from Fitzpatrick. pp.55
2.10 Pointers
"pass the arguments of a function by reference, rather than by value,
using pointers. This allows the two-way communication of information via arguments
du... |
ernestyalumni/CompPhys | CFitz/printfact4.c | <gh_stars>10-100
/* printfact4.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
2.11 Global
*/
/*
Program to print factorials of all integers
between 0 and 20
*/
/*
From Fitzpatrick in 2.11
"Global variables should be used sparingly in scientific programs (or any other type of program), since there ... |
ernestyalumni/CompPhys | moreCUDA/samples02/texdynamics/physlib/R2grid.h | <filename>moreCUDA/samples02/texdynamics/physlib/R2grid.h
/* R2grid.h
* R2 under discretization (discretize functor) to a grid
* <NAME> <EMAIL>
* 20161113
*/
#ifndef __R2GRID_H__
#define __R2GRID_H__
#include <array> // std::array
#include <vector> // std::vector
#include <cstdlib> // std::exit
#include <cmath> /... |
ernestyalumni/CompPhys | moreCUDA/LatticeBoltzmannmethod/LatticeBoltzmann2D/physlib/init.h | <reponame>ernestyalumni/CompPhys
/**
* init.h
* \file init.h
* Navier-Stokes equation solver in 2-dimensions, incompressible flow, by Lattice Boltzmann method
* \brief initialization, set initial conditions,
* Simulation of flow inside a 2D square cavity using the lattice Boltzmann method (LBM)
* \author <NAME>... |
ernestyalumni/CompPhys | moreCUDA/common/matmultShare.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/* multShare.h
* Matrix Multiplication using Shared Memory
* based on code from CUDA C Programming Guide
* <NAME> <EMAIL>
* 20160620
*/
typedef struct {
int Ni;
int Nj;
float* elements;
int stride;
} Matrix;
__global__ void MatMulkernel(const Matrix, const Ma... |
ernestyalumni/CompPhys | gslExamples/SO3blas.c | /* SO3blas.c */
// SO(3) Lie group implemented with GNU GSL
// cf. wikipedia, "Rotation_group_SO(3)#Infinitesimal_rotations"
// EY note : 20160519 Bizarrely, matrix multiplication isn't implemented
// in a straightforward manner with the gsl_matrix class;
// see blas (which I don't know what it is yet) and dgemm for ... |
ernestyalumni/CompPhys | CFitz/timing.c | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/* timing.c */
/*
Fitzpatrick. Computational Physics. 329.pdf
Timing
EY : 20160517 Compiling note:
cf. http://stackoverflow.com/questions/5248919/c-undefined-reference-to-sqrt-or-other-mathematical-functions
Answer from paxdiablo
"You may find that you h... |
ernestyalumni/CompPhys | moreCUDA/cudaforengineers/heat_2d/heat_2d.h | <filename>moreCUDA/cudaforengineers/heat_2d/heat_2d.h<gh_stars>10-100
/* heat_2d.h
* 2-dim. Laplace eq. (heat eq.) by finite difference with shared memory
* <NAME> <EMAIL>
* 20160626
*/
#ifndef __HEAT_2D_H__
#define __HEAT_2D_H__
struct uchar4;
// struct BC that contains all the boundary conditions
typedef struct... |
ernestyalumni/CompPhys | moreCUDA/heat3d/commonlib/finitediff.h | /* finitediff.h
* finite difference methods on a grid
* <NAME> <EMAIL>
* 20160710
*/
#ifndef __FINITEDIFF_H__
#define __FINITEDIFF_H__
#include "errors.h"
// I fixed the size of dev_c to be 4 because I don't anticipate that we'd need more accuracy
extern __constant__ float3 dev_cnus[4]; // i = x,y,z; j = 1,2,3... |
ernestyalumni/CompPhys | CFitz/random.c | /* random.c */
/*
Program to test operation of rand() function
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define N_MAX 10000000
int main()
{
int i, seed;
double sum_0, sum_1, mean, var, x;
/* Seed random number generator */
seed = time(NULL);
srand(seed);
/* Calculate mean and varian... |
ernestyalumni/CompPhys | moreCUDA/CURAND/gens2distri/XORMRGgens.h | /**
* @file : XORMRGgens.h
* @brief : Examples using cuRAND device API to generate pseudorandom numbers using either XORWOW or MRG32k3a generators, header file
* @details : This program uses the device CURAND API. The purpose of these examples is explore scope and compiling and modularity/separation issues wi... |
ernestyalumni/CompPhys | gslExamples/matrices.c | /* matrices.c */
// 8.4.13 Example programs for matrices of gsl-ref.pdf
// GNU GSL GNU Scientific Library reference book
#include <stdio.h>
#include <gsl/gsl_matrix.h>
int main (void) {
int i, j;
gsl_matrix * m = gsl_matrix_alloc (10, 3);
for (i = 0; i < 10; i++)
for (j = 0; j < 3; j++)
gsl_matrix_s... |
ernestyalumni/CompPhys | moreCUDA/cudaforengineers/dd_1d_shared/dd_1d_shared.h | <gh_stars>10-100
/* dd_1d_shared.h
* 1-dimensional double derivative (dd for '') by finite difference with global memory
* <NAME> <EMAIL>
* 20160625
*/
#ifndef __DD_1D_SHARED_H__
#define __DD_1D_SHARED_H__
void ddParallel(float *out, const float *in, int n, float h);
#endif // __DD_1D_SHARED_H__
|
ernestyalumni/CompPhys | Cpp/progs/ch03/complex.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/*
* cf. <NAME>, Computational Physics, University of Oslo (2015)
* http://www.mn.uio.no/fysikk/english/people/aca/mhjensen/
* <NAME> (I typed it up and made modifications)
* <EMAIL>
* MIT License
* cf. Chapter 3 Numerical differentiation and interpolation
* 3.... |
ernestyalumni/CompPhys | Cpp/progs/ch02/program1.c | <filename>Cpp/progs/ch02/program1.c
/*
* cf. <NAME>, Computational Physics, University of Oslo (2015)
* http://www.mn.uio.no/fysikk/english/people/aca/mhjensen/
* <NAME> (I typed it up and made modifications)
* <EMAIL>
* MIT License
* cf. Chapter 2 Introduction to C++ and Fortran
* 2.1.1 Scientific hello wor... |
ernestyalumni/CompPhys | moreCUDA/CURAND/CuRand/Uniform.h | <filename>moreCUDA/CURAND/CuRand/Uniform.h<gh_stars>10-100
//------------------------------------------------------------------------------
/// \file Uniform.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Sequence of pseudorandom floats uniformly distributed between 0.0
/// and 1.0
/// \url https://docs.nvidia.co... |
ernestyalumni/CompPhys | Cpp/math/Groups/GroupAxioms.h | //------------------------------------------------------------------------------
/// \file GroupAxioms.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Group axioms closure, identity, and inverse elements.
/// \ref Ch. 21 Class Hierarchies, 21.2.Design of Class Hierarchies
/// The C++ Programming Language, 4th Ed... |
ernestyalumni/CompPhys | Cpp/Cpp14/FileIO/FileIO.h | /**
* @file : FileIO.h
* @brief : File IO header file, with Python NumPy, in C++14,
* @details : class CSVRow
*
*
* @author : <NAME> <<EMAIL>>
* @date : 20171014
* @ref :
*
* https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ernestsaveschristmas%2bpaypal%40gmail%2ecom&lc=US&item_na... |
ernestyalumni/CompPhys | Cpp/Cpp14/MatrixclassMat/Mat/Mat.h | <gh_stars>10-100
/**
* @file Mat.h
* @brief C++11 class template for Matrices, ready for Matrix multiplication,
* and the taking of the transpose
* @author <NAME>, <<EMAIL>>
* @date 20170727
* */
#ifndef __MAT_H__
#define __MAT_H__
#include <array> // std::array
#include <vector> // std::vector
#include <nume... |
ernestyalumni/CompPhys | courses_notes/sparseMat/sparse_Unified.h | /**
* @file : sparse_Unified.h
* @brief : Sparse Matrices using CUDA Unified Memory, but for Compute Capability 5.X
* uses CUDA Unified Memory (Management)
* @author : <NAME> <EMAIL>
* @date : 20170522
* @ref : cf. https://www5.in.tum.de/lehre/vorlesungen/hpc/WS16/tutorial/sparse_02.pdf
*
* If you f... |
ernestyalumni/CompPhys | MonteCarlo/TimeEvolutionStateTransitions/TimeEvolution.h | <reponame>ernestyalumni/CompPhys
//------------------------------------------------------------------------------
/// \file TimeEvolution.h
/// \author <NAME>
/// \email <EMAIL>
/// \brief Discrete time evolution for a state of finite number of state
/// variables.
/// \url
/// \ref CompPhys.pdf
/// \details Discrete... |
ernestyalumni/CompPhys | CFitz/quadratic1.c | /* quadratic1.c
Fitzpatrick. Computational Physics. 329.pdf
2.8 Control Statements
EY : 20160517 Compiling note:
cf. http://stackoverflow.com/questions/5248919/c-undefined-reference-to-sqrt-or-other-mathematical-functions
Answer from paxdiablo
"You may find that you have to link with the math librar... |
ernestyalumni/CompPhys | moreCUDA/CUBLAS/036sgemm.c | /**
* @file : 036sgemm.cu
* @brief : cublasSgemm - matrix-matrix multiplication
* C = \alpha op(A) op(B) + \beta C
* @author : <NAME> <EMAIL>
* @date : 20170628
* @ref : cf. https://developer.nvidia.com/sites/default/files/akamai/cuda/files/Misc/mygpu.pdf
*
* If you find this code useful, fee... |
ernestyalumni/CompPhys | gslExamples/vectorviews.c | /* vectorviews.c */
// 8.4.13 Example programs for matrices of gsl-ref.pdf
// GNU GSL GNU Scientific Library reference book
// pp. 99,100
/*
Compiling advice:
gcc vectorviews.c -lgsl -lgslcblas -lm
*/
#include <math.h>
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
int main (void)
{
... |
ernestyalumni/CompPhys | moreCUDA/heat_2d_refactor/commonlib/finitediff.h | /* finitediff.h
* finite difference methods on a grid
* <NAME> <EMAIL>
* 20160710
*/
#ifndef __FINITEDIFF_H__
#define __FINITEDIFF_H__
#include "errors.h"
// I fixed the size of dev_c to be 4 because I don't anticipate that we'd need more accuracy
extern __constant__ float2 dev_cnus[4]; // i = x,y; j = 1,2,3,4... |
ernestyalumni/CompPhys | CFitz/quadratic.c | /* quadratic.c
Fitzpatrick. Computational Physics. 329.pdf
2.7 Structure of a C Program
EY : 20160517 Compiling note:
cf. http://stackoverflow.com/questions/5248919/c-undefined-reference-to-sqrt-or-other-mathematical-functions
Answer from paxdiablo
"You may find that you have to link with the math l... |
ernestyalumni/CompPhys | moreCUDA/LatticeBoltzmannmethod/LatticeBoltzmann2D_gfx/physlib/PDE.h | <reponame>ernestyalumni/CompPhys
/**
* PDE.h
* \file PDE.h
* Navier-Stokes equation solver in 2-dimensions, incompressible flow, by Lattice Boltzmann method
* \brief PDE, partial differential equation, dynamics
* Simulation of flow inside a 2D square cavity using the lattice Boltzmann method (LBM)
* \author <NA... |
ernestyalumni/CompPhys | Cpp/math/Groups/ComplexNumberGroup.h | /**
* @file : ComplexNumbersGroups.h
* @author : <NAME>
* @email : <EMAIL>
* @brief : Complex numbers as an Abelian group
* @details Concrete class - defining property is its representation is its
* definition
* @ref : 3.2.1.1 An Arithmetic Type, Ch. 3 A Tour of C++: Abstraction
* Mechanisms. Bjarn... |
ernestyalumni/CompPhys | moreCUDA/heat_2d_refactor/physlib/R2grid.h | <reponame>ernestyalumni/CompPhys
/* R2grid.h
* R2 under discretization (discretize functor) to a grid
* <NAME> <EMAIL>
* 20160701
*/
#ifndef __R2GRID_H__
#define __R2GRID_H__
#include <array> // std::array
#include <cmath> // expf
class Grid2d
{
public :
std::array<int,2> Ld;
std::array<float,2> ld;
std:... |
ernestyalumni/CompPhys | Cpp/math/Groups/Group.h | <reponame>ernestyalumni/CompPhys
/**
* @file : Groups.h
* @author : <NAME>
* @email : <EMAIL>
* @brief : Groups as an abstract type.
* @details A group
* @ref : 3.2.1.2 A Container, Ch. 3 A Tour of C++: Abstraction
* Mechanisms. Bjarne Stroustrup, The C++ Programming Language, 4th Ed.
*
* If you f... |
ernestyalumni/CompPhys | Cpp/Ising/Ising/FileIO/output.h | <reponame>ernestyalumni/CompPhys<gh_stars>10-100
/**
* @file : output.h
* @brief : process output after Metropolis algorithm header file, in C++11/14,
* @details : process output after Metropolis algorithm, in particular, struct Avg
*
* @author : <NAME> <<EMAIL>>
* @date : 20171231
* @ref : M. Hjo... |
mangesh2102000/Programming-Lab-CS112 | CS lab/midsem/midsem.c | <reponame>mangesh2102000/Programming-Lab-CS112
// Name of Coder : <NAME>
// Roll No. : 1801CS16
// Date : 5 March 2019
// Brief Objective of Program : Complete the tasks given in question paper (Mid-semester examination)
#include <stdio.h>
// Function to calculate GCD of N and P
int GCD(int N, int P)
{... |
mangesh2102000/Programming-Lab-CS112 | CS lab/ Assignment 1/prog1b.c | // Name of coder: <NAME>
// Roll No: 1801CS16
// Date Created: 15 Jan 2019
// Program to find out which mall one should go to, to avail maximum profit.
#include <stdio.h>
void main()
{
int a, b, c, d;
// Prompt user for input
printf("Enter the number of items to be bought for Jam, Toothpaste, Juice and Nutella: "... |
mangesh2102000/Programming-Lab-CS112 | CS lab/Assignment 5/prog5.c | // Name of coder : <NAME>
// Roll No : 1801cs16
// Date created : 12/02/2019
// Brief objective of the program : Finding neighbouring points and type of given point
#include <stdio.h>
int a1 = 5, a2 = 8;
int b1 = 6, b2 = 7;
int c1 = 6, c2 = 5;
int d1 = 2, d2 = 4;
int e1 = 3, e2 = 4;
int f1 = 5, f2 = 4;
int... |
mangesh2102000/Programming-Lab-CS112 | CS lab/Assignment 7/prog7.c | <reponame>mangesh2102000/Programming-Lab-CS112
// Name of Coder : <NAME>
// Roll No. : 1801CS16
// Date : 12/03/2019
// Brief Objective of Program : Using Recursion
#include <stdio.h>
// Function to calculate GCD of two integers
int GCD(int N, int P)
{
if(N % P == 0)
{
return P;
}
else
{
return... |
mangesh2102000/Programming-Lab-CS112 | CS lab/Assignment 9/prog9l.c | //Name: <NAME>
//Roll no. 1801cs16
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char keynum[1000];
char key1[1000];
int isa(char c)
{
if((c>='a' && c<='z') || (c>='A' && c<='Z'))
{ return 1;}
return 0;
}
char tou(char c)
{
if((c>='a' && c<='z'))
{
return (c-'a'+'A');
}
return c;
}
int prepare_... |
mangesh2102000/Programming-Lab-CS112 | CS lab/ Assignment 1/prog1a.c | // Name of coder: <NAME>
// Roll No: 1801CS16
// Date Created: 15 Jan 2019
// Program to design a simple calculator.
#include <stdio.h>
void main()
{
// Declare variables
int X;
float Y,Z;
// Get input from user
printf("Enter three numbers X (1: Addition or 2: Subtraction or 3: Multiplication or 4: Division), Y... |
mangesh2102000/Programming-Lab-CS112 | CS lab/Assignment 8/prog8.c | // Name of coder : <NAME>
// Roll No : 1801CS16
// Date created : 26th Mar 2019
// Brief objective of the program : Complete task given in Assignment 8
#include <stdio.h>
// Structure Definition
typedef struct student{
int roll_number;
char grades[6];
float CGPA;
}student;
// Function I to sort in increa... |
mangesh2102000/Programming-Lab-CS112 | CS lab/Assignment 2/prog2a.c | <reponame>mangesh2102000/Programming-Lab-CS112
// Name of coder: <NAME>
// Roll No: 1801CS16
// Date created: 22/01/2019
// Brief objective of the program: Determines the nature of triangle formed with the given points along with its area.(If they are not collinear)
#include <stdio.h>
void m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.