Skip to content

Instantly share code, notes, and snippets.

View pozdneev's full-sized avatar

Alexander Pozdneev pozdneev

View GitHub Profile
@pozdneev
pozdneev / ge-part-pivoting.f90
Created February 27, 2011 13:06
Gaussian elimination with partial pivoting using straightforward formulas and array syntax
!!---------------------------------------------------------------------------
! Gaussian elimination with partial pivoting using straightforward formulas
! and Fortran 90/95 features
!!---------------------------------------------------------------------------
! gfortran -ffree-form -Wall -Wextra -fopenmp
!!---------------------------------------------------------------------------
! [1] J. Demmel "Numerical Linear Algebra"
! [2] N. J. Nigham "Gaussian Elimination"
!
! ELIMINATION
@pozdneev
pozdneev / ge-partitioned.f90
Created February 27, 2011 17:14
Gaussian partitioned elimination without pivoting using straightforward formulas and BLAS routines
! Gaussian partitioned elimination without pivoting using straightforward
! formulas and BLAS routines
!!---------------------------------------------------------------------------
! gfortran -ffree-form -Wall -Wextra -lblas -fopenmp
!!---------------------------------------------------------------------------
!
! [1] J. Demmel "Numerical Linear Algebra"
! [2] N. J. Nigham "Gaussian Elimination"
!
! ELIMINATION
@pozdneev
pozdneev / ge-no-pivoting.f90
Created March 5, 2011 13:01
Gaussian elimination without pivoting using straightforward formulas, Fortran 90/95 syntax and BLAS routines
! Gaussian elimination without pivoting: straightforward formulas,
! Fortran 90/95 features, BLAS routines
!!---------------------------------------------------------------------------
! gfortran -ffree-form -Wall -Wextra -lblas -fopenmp
!!---------------------------------------------------------------------------
!
! [1] J. Demmel "Numerical Linear Algebra"
! [2] N. J. Nigham "Gaussian Elimination"
!
! ELIMINATION
@pozdneev
pozdneev / k-border-matrix.tex
Created March 6, 2011 12:19
Border matrix via kbordermatrix LaTeX package
% Border matrix
% latex filename.tex
% dvipng -T tight -D 150 filename.dvi
\documentclass{article}
\usepackage{kbordermatrix}
\begin{document}
\[
@pozdneev
pozdneev / chol-no-pivoting.f90
Created March 11, 2011 22:31
Cholesky decomposition without pivoting: straightforward formulas, Fortran 90/95 features and BLAS routines
! Cholesky decomposition without pivoting: straightforward formulas,
! Fortran 90/95 features and BLAS routines
!!---------------------------------------------------------------------------
! gfortran -ffree-form -Wall -Wextra -lblas -fopenmp
!!---------------------------------------------------------------------------
program chol
!!---------------------------------------------------------------------------
use omp_lib, only: omp_get_wtime
implicit none
@pozdneev
pozdneev / chol-partitioned.f90
Created March 11, 2011 22:32
Cholesky partitioned decomposition without pivoting: straightforward formulas and BLAS routines
! Cholesky partitioned decomposition without pivoting: straightforward
! formulas and BLAS routines
!!---------------------------------------------------------------------------
! gfortran -ffree-form -Wall -Wextra -lblas -fopenmp
!!---------------------------------------------------------------------------
program chol
!!---------------------------------------------------------------------------
use omp_lib, only: omp_get_wtime
implicit none
@pozdneev
pozdneev / virtual-function-table.cpp
Created April 2, 2011 12:51
Virtual function table and destructors
/*
* This example demonstrates the significance of understanding the moments
* of virtual function table creation, filling, and "deallocation".
*/
#include <iostream>
class A {
public:
~A() {
@pozdneev
pozdneev / templates-and-multiple-inheritance.cpp
Created September 9, 2012 07:55
Templates and multiple inheritance
// The program demonstrates concepts of templates and multiple inheritance.
// It is allowed to inherit from template classes.
// The inherited classes are allowed to add new template parameters.
//
// g++ -Wall -Wextra templates-and-multiple-inheritance.cpp
#include <iostream>
template <class T>
struct A {
@pozdneev
pozdneev / template-specialization.cpp
Created September 9, 2012 14:27
Template specialization
// Template specialization allows us to (a) provide different implementation
// based on a template parameter; (b) add extra methods to one templated
// class based on its type, but not to other templates.
//
// Inspired by
// http://www.cprogramming.com/tutorial/template_specialization.html
//
// Here, we demonstrate template specialization for a vector container.
// Vector of boolean values can be optimized for space allocation.
// Vector of boolean values can have an extra method that negates all
@pozdneev
pozdneev / rounding.F90
Created August 31, 2014 09:16
Demonstration of various rounding/truncation methods in Fortran
! Demonstration of various rounding/truncation methods in Fortran
!
! ## Compilation line:
! gfortran -Wall -Wextra rounding.F90
!
! ## Output:
! a: -1.6 -1.4 1.4 1.6
! int(a): -1 -1 1 1
! nint(a): -2 -1 1 2
! ceiling(a): -1 -1 2 2