# Function Class¶

The function class provides a wrapper around a function $$f$$ posed on some domain $$\mathcal{D} \subset \mathbb{R}^m$$.

## Design Considerations¶

Often-times functions coming from engineering applications come in application units, e.g., in meters, Pascals, etc. The trouble is that these units are often poorly scaled with respect to each other, causing numerical issues. Hence, one of the first steps is to restate the problem on the normalized domain: an affine transform of $$\mathcal{D}$$ into the unit box $$[-1,1]^m$$. One of the roles of the Function class is to transparently handle working in the normalized domain so that no changes are needed for the functions provided.

## Function Class API¶

class psdr.Function(funs, domain, grads=None, fd_grad=None, vectorized=False, kwargs={}, dask_client=None, return_grad=False)[source]

Wrapper around function specifying the domain

Provided a function $$f: \mathcal{D} \subset \mathbb{R}^m \to \mathbb{R}^d$$, and a domain $$\mathcal{D}$$, this class acts as a wrapper for both. The key contribution of this class is to provide access to the function on the normalized domain $$\mathcal{D}_{\text{norm}}$$ that is a subset of the $$[-1,1]^m$$ cube; i.e.,

$\mathcal{D}_{\text{norm}} \subset [-1,1]^m \subset \mathbb{R}^m.$
Parameters: fun (function or list of functions) – Either a python function or a list of functions to evaluate domain (Domain) – The domain on which the function is posed vectorized (bool, default: False) – If True, the functions are vectorized for use with numpy. kwargs (dict, default: empty) – Keyword arguments to pass to the functions when evaluating function dask_client (dask.distributed.Client) – Client to use for multiprocessing
{"ft_lang_label":"__label__en","ft_lang_prob":0.7475661,"math_prob":0.9910578,"size":1740,"snap":"2019-51-2020-05","text_gpt3_token_len":453,"char_repetition_ratio":0.16129032,"word_repetition_ratio":0.0,"special_character_ratio":0.25114942,"punctuation_ratio":0.13354038,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9994103,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-27T14:07:37Z\",\"WARC-Record-ID\":\"<urn:uuid:5d049aaf-3cc8-41e8-8a62-94933124895a>\",\"Content-Length\":\"13784\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:854c5d98-4705-46f0-a634-e02073166d6e>\",\"WARC-Concurrent-To\":\"<urn:uuid:7695d759-65b0-458e-b566-d1fe6366037c>\",\"WARC-IP-Address\":\"104.208.221.96\",\"WARC-Target-URI\":\"https://psdr.readthedocs.io/en/latest/function.html\",\"WARC-Payload-Digest\":\"sha1:ZJDXIR4QXEW7TCIJ3GY34DXVN3ZOGRRH\",\"WARC-Block-Digest\":\"sha1:4EANO7SFQ66QGVI324OXCTX65XW73DI4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251700675.78_warc_CC-MAIN-20200127112805-20200127142805-00219.warc.gz\"}"}