#! /usr/bin/env python # -*- coding: utf-8 -*- """ Divers codes à essayer pour manipuler des tableaux "array" """ import numpy as np a = np.array([[1,2],[3,4]]) b = np.array([[1,1],[1,1]]) c = a + b # addition terme à terme print(c, c.ndim, c.shape, c.dtype) d =a * b # multiplication terme à terme print(d, d.ndim, d.shape, d.dtype) e = np.dot(a,b) # multiplication matricielle print(e, e.ndim, e.shape, e.dtype) f = np.sin(np.pi*0.5*a) # fonction mathématique et adaptation automatique du type print(f, f.ndim, f.shape, f.dtype) g = np.transpose(a) # transposition print(g, g.ndim, g.shape, g.dtype) print(np.sum(a),np.min(a), np.max(a)) # somme des éléments, minimum, maximum