03/06/80 apl_erf_.pl1.info Function: This info segment gives a sample pl1 program than can be called as an external function from within apl. The sample program is a monadic, scalar function (meaning that it is called with exactly one argument, that it operates on each element of the input argument independently of the other elements, and that the shape of the result is the same as the shape of the input argument). The sample program computes the "error function" of its input argument, using the PL/I builtin "erf". The sample program may be extracted from this info segment, compiled and executed, if desired. The necessary include segments are located in the directory >ldd>unbundled>include (except at MIT, where they are in >ldd>include). Text of PL/I program: /* ****************************************************** * * * * * Copyright (c) 1972 by Massachusetts Institute of * * Technology and Honeywell Information Systems, Inc. * * * * * ****************************************************** */ /* APL External Function to implement the PL/I 'erf' builtin for APL */ /* Written October 15, 1975 by Paul Green */ /* Modified 780927 by PG to fix bug 335 (type field of result not being setup properly). Also switched to apl_push_stack_ subroutine. */ /* format: style3 */ apl_erf_: procedure (operators_argument); /* automatic */ declare n_words fixed bin (19), /* number of words to allocate on value stack */ result ptr, /* pointer to result data array */ result_vb ptr, /* pointer to result value bead */ right ptr, /* pointer to right data array */ right_vb ptr; /* pointer to right value bead */ /* builtins */ declare (addrel, erf, size, string, substr, rel) builtin; /* include files */ %include apl_external_function; %page; /* program */ /* Usage in APL: )MFN ERF APL_ERF_ RESULT -< ERF V */ right_vb = operators_argument.operands (2).value; /* Get ptr to right argument */ if ^right_vb -> value_bead.value /* Make sure argument is a value bead */ then go to domain_error_right; if ^right_vb -> value_bead.numeric_value /* Make sure argument is numeric */ then go to domain_error_right; right = right_vb -> value_bead.data_pointer; /* Point to data array */ data_elements = right_vb -> value_bead.total_data_elements; if operators_argument.operands (2).on_stack then do; /* overwrite operand with result */ result_vb = right_vb; result = right; end; else do; /* Right operand isn't on stack...can't overlay...build new result bead. */ /* Calculate size of result bead. Note that result data array */ /* must be double-word aligned. */ number_of_dimensions = right_vb -> value_bead.rhorho; n_words = size (value_bead) + size (numeric_datum) + 1; /* Allocate space on the value stack for the result bead. */ result_vb = apl_push_stack_ (n_words); /* Set pointer to data array. Double-word align it. */ result = addrel (result_vb, size (value_bead)); if substr (rel (result), 18, 1) then result = addrel (result, 1); /* Initialize new value bead. */ result_vb -> value_bead.total_data_elements = data_elements; result_vb -> value_bead.rhorho = number_of_dimensions; result_vb -> value_bead.data_pointer = result; if number_of_dimensions > 0 /* Zero-length arrays are invalid in PL/I, so check first */ then result_vb -> value_bead.rho (*) = right_vb -> value_bead.rho (*); end; /* Give result bead the correct data type */ string (result_vb -> value_bead.type) = numeric_value_type; /* The result value bead is all set up. Perform the operation */ result -> numeric_datum (*) = erf (right -> numeric_datum (*)); operators_argument.result = result_vb; return; domain_error_right: operators_argument.where_error = operators_argument.where_error - 1; /* Mark right operand */ operators_argument.error_code = apl_error_table_$domain; return; %page; %include apl_push_stack_fcn; end /* apl_erf_ */; ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group BULL including BULL HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell BULL Inc., Groupe BULL and BULL HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, BULL or BULL HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by BULL HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved