#include <slate.h>
int main() {
//
// Vectors and Matrices with the same dimensions and type can be
// compared element-by-element, producing a new Vector or Matrix with
// the maximum of each element pair.
//
Matrix<double> a(1,2,1,2,19.0);
Matrix<double> b(1,2,1,2,10.0);
a(1,1) = 4.0;
cout << max(a, b) << endl;
Vector<int> d(1,6,4);
Vector<int> e(1,6,2);
d(1) = 0;
cout << max(d, e) << endl;
//
// Scalar values can be compared with Vector or Matrix elements to
// produce a new Vector or Matrix.
//
cout << max(5.0, a) << endl;
cout << max(a, 5.0) << endl;
cout << max(3, d) << endl;
cout << max(d, 3) << endl;
//
// Forming Vectors and Matrices with *minimum* values.
//
cout << min(a,b) << endl;
cout << min(d,e) << endl;
cout << min(5.0, a) << endl;
cout << min(a, 5.0) << endl;
cout << min(3, d) << endl;
cout << min(d, 3) << endl;
//
// We can also return the minimum or maximum element of a Vector or Matrix.
//
cout << min(a) << " " << max(a) << endl;
cout << min(d) << " " << max(d) << endl;
}
#include <slate.h>
int main() {
//
// We can sum all elements of a Vector or Matrix.
//
Matrix<double> a(1,2,1,2,19.0);
Vector<double> b(1,9,10.0);
cout << sum(a) << endl;
cout << sum(b) << endl;
}
#include <slate.h>
int main() {
//
// Take each element to some power.
//
Matrix<double> a(1,2,1,2,2.0);
Vector<double> b(1,9,3.0);
cout << pow(a,4) << endl;
cout << pow(b,3) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << pow(c,4) << endl;
cout << pow(d,3) << endl;
}
#include <slate.h>
int main() {
//
// Take the absolute values of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,-3.0);
cout << abs(a) << endl;
cout << abs(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << abs(c) << endl;
cout << abs(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the square roots of each element.
//
Matrix<double> a(1,2,1,2,2.0);
Vector<double> b(1,9,3.0);
cout << sqrt(a) << endl;
cout << sqrt(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << sqrt(c) << endl;
cout << sqrt(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the square of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << sqr(a) << endl;
cout << sqr(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << sqr(c) << endl;
cout << sqr(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the cube of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << cube(a) << endl;
cout << cube(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << cube(c) << endl;
cout << cube(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the sine of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << sin(a) << endl;
cout << sin(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << sin(c) << endl;
cout << sin(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the cosine of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << cos(a) << endl;
cout << cos(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << cos(c) << endl;
cout << cos(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the tangent of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << tan(a) << endl;
cout << tan(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << tan(c) << endl;
cout << tan(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the hyperbolic sine of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << sinh(a) << endl;
cout << sinh(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << sinh(c) << endl;
cout << sinh(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the hyperbolic cosine of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << cosh(a) << endl;
cout << cosh(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << cosh(c) << endl;
cout << cosh(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the hyperbolic tangent of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << tanh(a) << endl;
cout << tanh(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << tanh(c) << endl;
cout << tanh(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the exponential of each element.
//
Matrix<double> a(1,2,1,2,-2.0);
Vector<double> b(1,9,3.0);
cout << exp(a) << endl;
cout << exp(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << exp(c) << endl;
cout << exp(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the natural (base-e) logarithm of each element.
//
Matrix<double> a(1,2,1,2,2.0);
Vector<double> b(1,9,3.0);
cout << ln(a) << endl;
cout << ln(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << ln(c) << endl;
cout << ln(d) << endl;
//
// Take the base-10 logarithm of each element.
//
cout << log10(a) << endl;
cout << log10(b) << endl;
//
// The Matrix or Vector can have complex elements.
//
cout << log10(c) << endl;
cout << log10(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the complex conjugate of each element. This is only sensible
// for complex Matrices and Vectors.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << conj(c) << endl;
cout << conj(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the real component of each element. This is only sensible
// for complex Matrices and Vectors.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << real(c) << endl;
cout << real(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the imaginary component of each element. This is only sensible
// for complex Matrices and Vectors.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
cout << imag(c) << endl;
cout << imag(d) << endl;
}
#include <slate.h>
int main() {
//
// Take the complex argument of each element. This is only sensible
// for complex Matrices and Vectors.
//
Matrix< complex<double> > c(1,2,1,2,complex<double>(2.0,1.0));
Vector< complex<double> > d(1,9,complex<double>(3.0,2.0));
Vector< complex<double> > e(1,9,complex<double>(-3.0,-2.0));
Vector< complex<double> > f(1,9,complex<double>(3.0,-2.0));
cout << arg(c) << endl;
cout << arg(d) << endl;
cout << arg(e) << endl;
cout << arg(f) << endl;
}