forked from johannesgerer/jburkardt-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chrpak.html
571 lines (546 loc) · 16.3 KB
/
chrpak.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
<html>
<head>
<title>
CHRPAK - Strings and Characters
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
CHRPAK <br> Strings and Characters
</h1>
<hr>
<p>
<b>CHRPAK</b>
is a C++ library which
handles characters and strings.
</p>
<p>
<b>CHRPAK</b> began when I simply wanted to be able to capitalize
a string. Now it has expanded to a number of interesting uses.
Many unusual situations are provided for, including
<ul>
<li>
string '31.2' <=> numeric value 31.2;
</li>
<li>
uppercase <=> lowercase;
</li>
<li>
removal of control characters or blanks;
</li>
<li>
sorting, merging, searching.
</li>
</ul>
</p>
<p>
Many of the routine names begin with the name of the data type they
operate on:
<ul>
<li>
<b>B4</b> - a 4 byte word;
</li>
<li>
<b>CH</b> - a character;
</li>
<li>
<b>CHVEC</b> - a vector of characters;
</li>
<li>
<b>DEC</b> - a decimal fraction;
</li>
<li>
<b>DIGIT</b> - a character representing a numeric digit;
</li>
<li>
<b>I4</b> - an integer;
</li>
<li>
<b>R4</b> - a real;
</li>
<li>
<b>R8</b> - a double precision real;
</li>
<li>
<b>RAT</b> - a ratio I/J;
</li>
<li>
<b>S</b> - a string;
</li>
<li>
<b>SVEC</b> - a vector of strings;
</li>
<li>
<b>SVECI</b> - a vector of strings, implicitly capitalized;
</li>
</ul>
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>CHRPAK</b> is available in
<a href = "../../c_src/chrpak/chrpak.html">a C version</a> and
<a href = "../../cpp_src/chrpak/chrpak.html">a C++ version</a> and
<a href = "../../f77_src/chrpak/chrpak.html">a FORTRAN77 version</a> and
<a href = "../../f_src/chrpak/chrpak.html">a FORTRAN90 version</a> and
<a href = "../../m_src/chrpak/chrpak.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
Carl Branden, John Tooze,<br>
Introduction to Protein Structure,<br>
Second Edition,<br>
Garland Publishing, 1999,<br>
ISBN: 0815323050,<br>
LC: QP551.B7635.
</li>
<li>
Paul Bratley, Bennett Fox, Linus Schrage,<br>
A Guide to Simulation,<br>
Second Edition,<br>
Springer, 1987,<br>
ISBN: 0387964673,<br>
LC: QA76.9.C65.B73.
</li>
<li>
IEEE Standards Committee 754,<br>
IEEE Standard for Binary Floating Point Arithmetic,<br>
ANSI/IEEE Standard 754-1985,<br>
SIGPLAN Notices,<br>
Volume 22, Number 2, 1987, pages 9-25.
</li>
<li>
Donald Knuth,<br>
The Art of Computer Programming,<br>
Volume 3, Sorting and Searching,<br>
Second Edition,<br>
Addison Wesley, 1998,<br>
ISBN: 0201896850,<br>
LC: QA76.6.K64.
</li>
<li>
Albert Nijenhuis, Herbert Wilf,<br>
Combinatorial Algorithms for Computers and Calculators,<br>
Academic Press, 1978,<br>
ISBN: 0-12-519260-6,<br>
LC: QA164.N54.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "chrpak.cpp">chrpak.cpp</a>, the source code;
</li>
<li>
<a href = "chrpak.hpp">chrpak.hpp</a>, the include file;
</li>
<li>
<a href = "chrpak.sh">chrpak.sh</a>,
commands to compile the source code.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "chrpak_prb.cpp">chrpak_prb.cpp</a>, the calling program;
</li>
<li>
<a href = "chrpak_prb.sh">chrpak_prb.sh</a>,
commands to compile and run the calling program;
</li>
<li>
<a href = "chrpak_prb_output.txt">chrpak_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>A_TO_I4</b> returns the index of an alphabetic character.
</li>
<li>
<b>BASE_TO_I4</b> returns the value of an integer represented in some base.
</li>
<li>
<b>BYTE_TO_INT</b> converts 4 bytes into an unsigned integer.
</li>
<li>
<b>CH_CAP</b> capitalizes a single character.
</li>
<li>
<b>CH_COUNT_CVEC_ADD</b> adds a character vector to a character count.
</li>
<li>
<b>CH_COUNT_FILE_ADD</b> adds characters in a file to a character count.
</li>
<li>
<b>CH_COUNT_INIT</b> initializes a character count.
</li>
<li>
<b>CH_COUNT_PRINT</b> prints a set of character counts.
</li>
<li>
<b>CH_COUNT_S_ADD</b> adds a character string to a character histogram.
</li>
<li>
<b>CH_EQI</b> is true if two characters are equal, disregarding case.
</li>
<li>
<b>CH_INDEX_FIRST</b> finds the first occurrence of a character in a string.
</li>
<li>
<b>CH_INDEX_LAST</b> finds the last occurrence of a character in a string.
</li>
<li>
<b>CH_IS_ALPHA</b> is TRUE if a charaacter is alphabetic.
</li>
<li>
<b>CH_IS_ALPHANUMERIC</b> is TRUE if a character is alphanumeric.
</li>
<li>
<b>CH_IS_CONTROL</b> is TRUE if a character is a control character.
</li>
<li>
<b>CH_IS_DIGIT</b> returns TRUE if a character is a decimal digit.
</li>
<li>
<b>CH_IS_FORMAT_CODE</b> returns TRUE if a character is a FORTRAN format code.
</li>
<li>
<b>CH_IS_LOWER</b> is TRUE if C is a lowercase alphabetic character.
</li>
<li>
<b>CH_IS_PRINTABLE</b> determines if a character is printable.
</li>
<li>
<b>CH_IS_SPACE</b> is TRUE if a character represents "white space".
</li>
<li>
<b>CH_IS_UPPER</b> is TRUE if C is an uppercase alphabetic character.
</li>
<li>
<b>CH_LOW</b> lowercases a single character.
</li>
<li>
<b>CH_PAD</b> "pads" a character in a string with a blank on either side.
</li>
<li>
<b>CH_READ</b> reads one character from a binary file.
</li>
<li>
<b>CH_SCRABBLE</b> returns the character on a given Scrabble tile.
</li>
<li>
<b>CH_SWAP</b> swaps two characters.
</li>
<li>
<b>CH_TO_DIGIT</b> returns the integer value of a base 10 digit.
</li>
<li>
<b>CH_TO_DIGIT_BIN</b> returns the integer value of a binary digit.
</li>
<li>
<b>CH_TO_DIGIT_OCT</b> returns the integer value of an octal digit.
</li>
<li>
<b>CH_TO_ROT13</b> converts a character to its ROT13 equivalent.
</li>
<li>
<b>CH_UNIFORM</b> returns a random character in a given range.
</li>
<li>
<b>CH_WRITE</b> writes one character to a binary file.
</li>
<li>
<b>CHARSTAR_ADJUSTL</b> flushes a CHAR* string left.
</li>
<li>
<b>CHARSTAR_CAT</b> concatenates two CHAR*'s to make a third.
</li>
<li>
<b>CHARSTAR_EQI</b> reports whether two CHAR*'s are equal, ignoring case.
</li>
<li>
<b>CHARSTAR_LEN_TRIM</b> returns the length of a CHAR* to the last nonblank.
</li>
<li>
<b>DIGIT_BIN_TO_CH</b> returns the character representation of a binary digit.
</li>
<li>
<b>DIGIT_INC</b> increments a decimal digit.
</li>
<li>
<b>DIGIT_OCT_TO_CH</b> returns the character representation of an octal digit.
</li>
<li>
<b>DIGIT_TO_CH</b> returns the base 10 digit character corresponding to a digit.
</li>
<li>
<b>GETBITS</b> returns N bits from an unsigned int X, beginning at position P.
</li>
<li>
<b>HEX_DIGIT_TO_I4</b> converts a hexadecimal digit to an I4.
</li>
<li>
<b>HEX_TO_BINARY_DIGITS</b> converts a hexadecimal digit to 4 binary digits.
</li>
<li>
<b>HEX_TO_I4</b> converts a hexadecimal string to its integer value.
</li>
<li>
<b>I4_HUGE</b> returns a "huge" I4, usually the largest legal signed int.
</li>
<li>
<b>I4_INPUT</b> prints a prompt string and reads an I4 from the user.
</li>
<li>
<b>I4_LOG_10</b> returns the whole part of the logarithm base 10 of an I4.
</li>
<li>
<b>I4_MAX</b> returns the maximum of two I4's.
</li>
<li>
<b>I4_MIN</b> returns the smaller of two I4's.
</li>
<li>
<b>I4_SWAP</b> switches two I4's.
</li>
<li>
<b>I4_TO_A</b> returns the I-th alphabetic character.
</li>
<li>
<b>I4_TO_AMINO_CODE</b> converts an integer to an amino code.
</li>
<li>
<b>I4_TO_HEX_DIGIT</b> converts a (small) I4 to a hexadecimal digit.
</li>
<li>
<b>I4_TO_ISBN</b> converts an I4 to an ISBN digit.
</li>
<li>
<b>I4_TO_MONTH_ABB</b> returns an abbreviated month name.
</li>
<li>
<b>I4_TO_S</b> converts an I4 to a string.
</li>
<li>
<b>I4_TO_STRING</b> converts an I4 to a C++ string.
</li>
<li>
<b>I4_TO_UNARY</b> produces the "base 1" representation of an I4.
</li>
<li>
<b>I4_UNIFORM</b> returns a scaled pseudorandom I4.
</li>
<li>
<b>I4VEC_INDICATOR</b> sets an I4VEC to the indicator vector.
</li>
<li>
<b>I4VEC_PRINT</b> prints an I4VEC.
</li>
<li>
<b>INT_TO_BYTE</b> converts an unsigned integer into 4 bytes.
</li>
<li>
<b>ISBN_TO_I4</b> converts an ISBN character into an I4.
</li>
<li>
<b>PERM_CHECK</b> checks that a vector represents a permutation.
</li>
<li>
<b>PERM_UNIFORM</b> selects a random permutation of N objects.
</li>
<li>
<b>PRINT_SIZES</b> reports the size in bytes of various data types.
</li>
<li>
<b>R4_ABS</b> returns the absolute value of an R4.
</li>
<li>
<b>R4_NINT</b> returns the nearest integer to an R4.
</li>
<li>
<b>R4_TO_STRING</b> converts an R4 to a C++ string.
</li>
<li>
<b>R8_TO_STRING</b> converts an R8 to a C++ string.
</li>
<li>
<b>R8_UNIFORM_01</b> returns a unit pseudorandom R8.
</li>
<li>
<b>REVERSE_BYTES_FLOAT</b> reverses the four bytes in a float.
</li>
<li>
<b>REVERSE_BYTES_INT</b> reverses the four bytes in an int.
</li>
<li>
<b>S_ADJUSTL</b> flushes a string left.
</li>
<li>
<b>S_BEGIN</b> reports whether string 1 begins with string 2, ignoring case.
</li>
<li>
<b>S_BEHEAD_SUBSTRING</b> "beheads" a string, removing a given substring.
</li>
<li>
<b>S_BLANK_DELETE</b> removes blanks and left justifies the remainder.
</li>
<li>
<b>S_BLANKS_DELETE</b> replaces consecutive blanks by one blank.
</li>
<li>
<b>S_CAP</b> capitalizes all the characters in a string.
</li>
<li>
<b>S_CH_COUNT</b> counts occurrences of a particular character in a string.
</li>
<li>
<b>S_CONTROL_BLANK</b> replaces control characters with blanks.
</li>
<li>
<b>S_EQI</b> reports whether two strings are equal, ignoring case.
</li>
<li>
<b>S_ESCAPE_TEX</b> de-escapes TeX escape sequences.
</li>
<li>
<b>S_FIRST_CH</b> points to the first occurrence of a character in a string.
</li>
<li>
<b>S_FIRST_NONBLANK</b> points to the first nonblank character in a string.
</li>
<li>
<b>S_INC_C</b> "increments" the characters in a string.
</li>
<li>
<b>S_INC_N</b> increments the digits in a string.
</li>
<li>
<b>S_LAST_CH</b> points to the last occurrence of a character in a string.
</li>
<li>
<b>S_LEN_TRIM</b> returns the length of a string to the last nonblank.
</li>
<li>
<b>S_LOW</b> lowercases a string.
</li>
<li>
<b>S_NEWLINE_TO_NULL</b> replaces carriage returns or newlines by nulls.
</li>
<li>
<b>S_NONALPHA_DELETE</b> removes nonalphabetic characters from a string.
</li>
<li>
<b>S_REPLACE_CH</b> replaces all occurrences of one character by another.
</li>
<li>
<b>S_REVERSE</b> reverses the characters in a string.
</li>
<li>
<b>S_S_SUBANAGRAM</b> determines if S2 is a "subanagram" of S1.
</li>
<li>
<b>S_S_SUBANAGRAM_SORTED</b> determines if S2 is a "subanagram" of S1.
</li>
<li>
<b>S_SORT_A</b> sorts a string into ascending order.
</li>
<li>
<b>S_SUBSTRING</b> returns a substring of a given string.
</li>
<li>
<b>S_TAB_BLANK</b> replaces each TAB character by a space.
</li>
<li>
<b>S_TO_FORMAT</b> reads a FORTRAN format from a string.
</li>
<li>
<b>S_TO_I4</b> reads an I4 from a string.
</li>
<li>
<b>S_TO_I4VEC</b> reads an I4VEC from a string.
</li>
<li>
<b>S_TO_L</b> reads an L from a string.
</li>
<li>
<b>S_TO_R4</b> reads an R4 from a string.
</li>
<li>
<b>S_TO_R4VEC</b> reads an R4VEC from a string.
</li>
<li>
<b>S_TO_R8</b> reads an R8 from a string.
</li>
<li>
<b>S_TO_R8VEC</b> reads an R8VEC from a string.
</li>
<li>
<b>S_TO_ROT13</b> "rotates" the alphabetical characters in a string by 13 positions.
</li>
<li>
<b>S_TRIM</b> promotes the final null forward through trailing blanks.
</li>
<li>
<b>S_WORD_CAP</b> capitalizes the first character of each word in a string.
</li>
<li>
<b>S_WORD_COUNT</b> counts the number of "words" in a string.
</li>
<li>
<b>S_WORD_EXTRACT_FIRST</b> extracts the first word from a string.
</li>
<li>
<b>SORT_HEAP_EXTERNAL</b> externally sorts a list of items into ascending order.
</li>
<li>
<b>SWAP_BYTES_FLOAT</b> swaps pairs of bytes in a float.
</li>
<li>
<b>SWAP_BYTES_INT</b> swaps pairs of bytes in an int.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
<li>
<b>WORD_NEXT_READ</b> "reads" words from a string, one at a time.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../cpp_src.html">
the C++ source codes</a>.
</p>
<hr>
<i>
Last revised on 27 April 2011.
</i>
<!-- John Burkardt -->
</body>
</html>