ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
PB_Clastnb.c
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2 *
3 * -- PBLAS auxiliary routine (version 2.0) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * April 1, 1998
7 *
8 * ---------------------------------------------------------------------
9 */
10 /*
11 * Include files
12 */
13 #include "../pblas.h"
14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
18 
19 #ifdef __STDC__
20 int PB_Clastnb( int N, int I, int INB, int NB )
21 #else
22 int PB_Clastnb( N, I, INB, NB )
23 /*
24 * .. Scalar Arguments ..
25 */
26  int I, INB, N, NB;
27 #endif
28 {
29 /*
30 * Purpose
31 * =======
32 *
33 * PB_Clastnb returns the global number of matrix rows or columns of the
34 * last block, if N rows or columns are given out starting from the glo-
35 * bal index I. Note that if N is equal 0, this routine returns 0.
36 *
37 * Arguments
38 * =========
39 *
40 * N (global input) INTEGER
41 * On entry, N specifies the number of rows/columns being dealt
42 * out. N must be at least zero.
43 *
44 * I (global input) INTEGER
45 * On entry, I specifies the global index of the matrix entry.
46 * I must be at least zero.
47 *
48 * INB (global input) INTEGER
49 * On entry, INB specifies the size of the first block of the
50 * global matrix distribution. INB must be at least one.
51 *
52 * NB (global input) INTEGER
53 * On entry, NB specifies the size of the blocks used to parti-
54 * tion the matrix. NB must be at least one.
55 *
56 * -- Written on April 1, 1998 by
57 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
58 *
59 * ---------------------------------------------------------------------
60 */
61 /*
62 * .. Local Scalars ..
63 */
64  int lnbt;
65 /* ..
66 * .. Executable Statements ..
67 *
68 */
69  if( ( lnbt = I + N - INB ) > 0 )
70  {
71  lnbt = lnbt - NB * ( ( NB + lnbt - 1 ) / NB - 1 );
72  return( MIN( lnbt, N ) );
73  }
74  else
75  {
76  return( N );
77  }
78 /*
79 * End of PB_Clastnb
80 */
81 }
PB_Clastnb
int PB_Clastnb(int N, int I, int INB, int NB)
Definition: PB_Clastnb.c:22
MIN
#define MIN(a_, b_)
Definition: PBtools.h:76