# -*- coding: utf-8 -*-
"""
Created on Mon Mar 14 18:38:02 2011

@author: FRANCES
"""
import numpy as np

def prodmatmat(A,B):
    """
    Prodotto matrice matrice
    """
    na=A.shape[0]
    ma=A.shape[1]
    nb=B.shape[0]
    mb=B.shape[1]
    C = np.zeros((na,mb))
  
    if (ma != nb):
       error ('il numero di colonne di A deve essere uguale al numero di righe di B')
       

    for i in range(0,na):
        for j in range(0,mb):
            C[i,j] = 0
            for k in range(0,ma):
                C[i,j] = C[i,j] + A[i,k]*B[k,j]
        
    return C
    
def hilb(n):
     """"
     Matrice di Hilbert
     """
     H = np.zeros([n,n])
     for i in range(0,n):
         for j in range(0,n):
             H[i,j] = 1.0/(i+1+j)
     return H 


def generaMatrice(n):
          A=np.zeros([n,n])
          A=np.asmatrix(A)
          for i in range(0,n): 
                 for j in range(0,n):
                     A[i,j] = np.cos((i)*(j) * np.pi/(n-1))
          return A
                
