TheBoussinesqModel  3.2.1
 All Data Structures Files Functions Variables Typedefs Macros Pages
sorting.h File Reference

Go to the source code of this file.

Functions

int bubble_sort (LONGVECTOR *v, short print)
 
LONGVECTORaddresses_bubble_sort (LONGVECTOR *v, short print)
 
int bubble_sort_matrix (LONGVECTOR *v, LONGMATRIX *m, short print)
 

Function Documentation

LONGVECTOR* addresses_bubble_sort ( LONGVECTOR v,
short  print 
)
Parameters
v(LONGVECTOR *) - vector to be sorted
Date
March 2008
Author
Emanuele Cordano

it makes a bubble sort of the vector v (see the pseudo-code on http://en.wikipedia.org/wiki/Bubble_sort#Pseudocode_implementation )

Returns
the address of the "old" array to be sorted.

swap v->element[i] and v->element[i+1]

swap v->element[i] and v->element[i+1]

Definition at line 88 of file sorting.c.

References new_longvector(), LONGVECTOR::nh, LONGVECTOR::nl, and print_longvector_elements().

Referenced by bubble_sort_matrix().

int bubble_sort ( LONGVECTOR v,
short  print 
)
BGEOMETRY BUILDS THE MESH FROM A RASTER FOR THE BOUSSINESQ MODEL

BGEOMETRY Version 0.9375 KMackenzie

file sorting.c

Copyright, 2009 Emanuele Cordano and Riccardo Rigon

This file is part of BGEOMETRY. BGEOMETRY is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BGEOMETRY is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

int swap(long a, long b) {

Parameters
longa,b two (long) integer numbers
Date
March 2009
Author
Emanuele Cordano;
Returns
0 if a>b and swaps a and b, 1 if a<=b
    long mk;

    if (a>b) {
            mk=a;
            a=b;
            b=mk;
            return 0;
    } else {
            return 1;
    }

    return 0;
Parameters
v(LONGVECTOR *) - vector to be sorted
Date
March 2008
Author
Emanuele Cordano

it makes a bubble sort of the vector v (see the pseudo-code on http://en.wikipedia.org/wiki/Bubble_sort#Pseudocode_implementation )

swap v->element[i] and v->element[i+1]

Definition at line 52 of file sorting.c.

References LONGVECTOR::nh, LONGVECTOR::nl, and print_longvector_elements().

int bubble_sort_matrix ( LONGVECTOR v,
LONGMATRIX m,
short  print 
)
Author
Emanuele Cordano
Date
March 2009
Parameters
v(LONGVECTOR *) - vector to be sorted
M(LONGMATRIX *) - matrix
print(short)

It sorts v and then replace

Definition at line 145 of file sorting.c.

References addresses_bubble_sort(), LONGMATRIX::ncl, LONGVECTOR::nh, LONGMATRIX::nrh, and LONGMATRIX::nrl.