2.8 Generate an n by m zero matrix

Mathematica

mat=Table[0,{3},{4}]
 

    {{0,0,0,0}, 
     {0,0,0,0}, 
     {0,0,0,0}}
 

 

Matlab

A=zeros(3,4)
 

A = 
     0     0     0     0 
     0     0     0     0 
     0     0     0     0
 

 

Maple

LinearAlgebra:-ZeroMatrix(3,4);
 

\[ \left [ {\begin {array}{cccc} 0&0&0&0\\ 0&0&0&0 \\ 0&0&0&0\end {array}} \right ] \]

 

Fortran

program f  implicit none 
  integer i 
  integer, parameter :: dp = kind(1.D0) 
  real(kind=dp), DIMENSION(3, 4):: A 
 
  A=0 
 
  do i=LBOUND(A, 1),UBOUND(A, 1) 
       print *,A(i,:) 
  end do 
end program f
 
tmp>gfortran -std=f2008 f.f90 
tmp>./a.out 
0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000 
0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000 
0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000
 

 

Ada

with Ada.Text_IO;              use Ada.Text_IO; 
with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays; 
 
procedure t1 is 
   A : Real_Matrix (1 .. 3, 1 .. 4) := (others => (others => 0.0)); 
begin 
   null; 
end t1;