/* * ps-lib.sli * * This file is part of NEST. * * Copyright (C) 2004 The NEST Initiative * * NEST 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 2 of the License, or * (at your option) any later version. * * NEST 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 NEST. If not, see <http://www.gnu.org/licenses/>. * */ /ps-lib ($Revision: 10098 $) provide %% Library for PS conforming operators which are not %% strictly needed by the startup process. /* BeginDocumentation Name: array - construct array with n zeros (PS) Synopsis: int array -> array Examples: 10 array ->[0 0 0 0 0 0 0 0 0 0] Author: docu by Sirko Straube */ /array trie [/integertype] { [] exch { 0 append_a } repeat_ } bind addtotrie def % PostScript's operator putinterval % % call: array integer array putinterval array % string integer string putinterval string % /* BeginDocumentation Name: putinterval - replace sections of an array/string Synopsis: string int string putinterval -> string array int array putinterval -> array Examples:(hello) 2 (xx) putinterval -> (hexxo) [1 2 3 4 5] 2 [(xx) 99] putinterval -> [1 2 (xx) 99 5] Author: docu by Sirko Straube References: Postscript language SeeAlso: getinterval */ /putinterval { size exch replace } bind def /* BeginDocumentation Name: trunc - Truncate decimals of a double Synopsis: double trunc -> int Examples: 3.123456 trunc -> 3 Author: docu by Sirko Straube SeeAlso: floor, ceil */ /trunc trie [/doubletype] { int_d double_i } addtotrie def /* BeginDocumentation Name: round - Round double to the nearest integer Description: Alternatives: Function round_d (undocumented) -> behaviour and synopsis are the same. Remarks: round_d is currently defined in SLI, could be implemented in C++ for efficiency. Author: introduced non-trie-variant round_d, Ruediger Kupper. SeeAlso: iround, floor, ceil */ /round trie [/doubletype] /round_d load addtotrie def /* BeginDocumentation Name: iround - Round and convert double to the nearest integer Synopsis: double round -> int Description: Round the argument to the nearest integer and converts it to type int. Examples: Remarks: Author: introduced non-trie-variant round_d, Ruediger Kupper. SeeAlso: iround, floor, ceil */ /iround_d {round_d int_d} bind def /iround trie [/doubletype] /iround_d load addtotrie def /* BeginDocumentation Name: ceil - Return nearest integer larger than or equal to the argument. Description: Alternatives: Function ceil_d (undocumented) -> behaviour and synopsis are the same. Parameters: The input argument must be of type integer or double. The output argument has the same type as the input argument. Examples: 2.87 ceil -> 3 1.001 ceil -> 2 Remarks: Note that for integer arguments, this function equals identity. Author: Ruediger Kupper, docu edited by Sirko Straube FirstVersion: 13.3.2003 SeeAlso: floor */ /ceil trie [/doubletype] /ceil_d load addtotrie [/integertype] {} addtotrie def /* BeginDocumentation Name: floor - Return nearest integer smaller than or equal to the argument. Description: Alternatives: Function floor_d (undocumented) -> behaviour and synopsis are the same. Parameters: The input argument must be of type integer or double. The output argument has the same type as the input argument. Examples: 1.1 floor == -> 1 2.9 floor == -> 2 Remarks: Note that for integer arguments, this function equals identity. Author: Ruediger Kupper, docu edited by Sirko Straube FirstVersion: 13.3.2003 SeeAlso: ceil */ /floor trie [/doubletype] /floor_d load addtotrie [/integertype] {} addtotrie def