# PWAS

Piece-Wise Affine Simplicial function object

## Contents

Class of MOBY-DIC TOOLBOX.

## Description

The pwas object describes a Piece-Wise Affine Simplicial function, i.e. a PWA function defined on a domain partitioned into regular regions called simplices. The simplicial partition is obtained by subdividing each of the nd domain components in segments, thus obtaining hyper-rectangles. Each of these hyper-rectangles is further partitioned into nd! simplices. If, for each component, the segments have the same length, the partition is uniform, otherwise it is non-uniform. Any pwas function can be expressed as weighted sum of basis functions:

where can be the , or basis.

NOTE: at the current release of the toolbox only alpha basis can be employed.

## Syntax

**fpwa = pwas()**

Builds an empty pwas object.

**fpwa = pwas(pwasObj)**

Builds a pwas object which is an exact copy of pwasObj.

**fpwa = pwas(D,P)**

Builds a pwas object which contains only the information about the domain and the simplicial partition. The weights are not set. D is a matrix specifying the domain in the form: P can be an array containing the number of subdivisions per dimensions (in case of uniform partition) or a cell array whose i-th element contains the i-th component of the vertices of the simplicial partition (for non-uniform partition).

**fpwa = pwas(D,P,w)**

Builds a complete pwas object by setting the domain, the partition and also the weights for the basis functions. In this way the function is completely defined.

**fpwa = pwas(D,P,w,basis)**

Builds a complete pwas object by setting the domain, the partition the weights for the basis functions and by specifying also which basis is used. In this way the function is completely defined. In this release the only choice for basis is 'alpha'.

## Properties

- np - number of subdivisions per dimension.
- nb - number of basis functions (equal to number of vertices of the simplicial partition.
- P - simplicial partition. P is a cell array whose i-th element contains the i-th component of the vertices of the simplicial partition.
- w - weights of the weighted sum of basis functions.
- basis - type of basis function used. In this release basis is always 'alpha'.
- uniform - boolean value indicating wether the simplicial partition is uniform or not.

## Methods

- basisFunction - computes the value of the alpha basis function in given points.
- eval - evaluates the pwas function.
- findSimplexVertices - Finds the vertices of the simplices containing given points
- generateSimulinkModel - generate a Simulink model for the simulation of the closed-loop system
- getBasis - gets the basis used to represent the pwas function.
- getCircuitPerformances - gets the performances of the circuits implementing the pwas function
- getClosedLoop - Gets the pwas function defining the closed loop system
- getNumberOfPartitions - gets the number of partitions for each dimension of the pwas function domain.
- getNumberOfSimplices - gets the number of simplices.
- getNumberOfVertices - gets the number of vertices of the simplicial partition of the pwas function. The number of vertices is the same as the number of basis functions.
- getPartition - gets the simplicial partition of the pwas function.
- getRegions - gets information about the requested polytope(s).
- getSimplices - Gets the vertices of all simplices of the simplicial partition
- isUniform - returns 1 if the simplicial partition is uniform, 0 otherwise.
- plot - plots the pwas function.
- setDomain - sets the domain over which the pwas function is defined.
- setNumberOfPartitions - sets the number of partitions for each dimension of the pwas function domain.
- setPartition - sets the simplicial partition of the pwas function.
- setWeights - sets the weights defining the pwas function.
- synthesize - generates the VHDL files describing the digital circuit which implements the pwas function.
- vertices - gets the vertices of the simplices of the domain partition.

## Private methods

- alphamex - Computes the value of a specified alpha basis in an array of points
- nonUniformToUniform - Maps a point P from a domain with non uniform partition to a domain with uniform partition
- triangulation2D - Generates the simplicial partition of a bidimensional domain
- writeInterface - Writes the VHDL code implementing block pwag_ser_interface or block pwag_par_interface in pwas circuit
- writeMemory - Writes the VHDL code implementing block Memory in pwas circuit
- writePackage - Writes the VHDL code implementing block pwag_ser_package or block pwag_par_package in pwas circuit
- writeTest - Writes the VHDL code implementing block test_pwag_ser_interface or block test_pwag_par_interface in pwas circuit
- writeTransformToUniform - Writes the VHDL code implementing block TransformToUniform in pwas circuit

## Acknowledgements

Contributors:

- Tomaso Poggi (tpoggi@essbilbao.org)

Copyright is with:

- Copyright (C) 2010 University of Genoa, Italy.