Answer the question
In order to leave comments, you need to log in
How to generate a rectangular matrix (of any dimension) with values from 0 to A?
Example (n columns = 3 (can be anything), m rows = whatever, matrix value from 0 to 2 (can be anything)):
1 0 0
1 1 0
1 0 1
1 1 1
2 0 0
2 1 0
2 0 1
2 1 1
2 2 0
2 2 1
2 0 2
2 1 2
2 2 2
Answer the question
In order to leave comments, you need to log in
For example, like this (python):
from random import randint
a, n, m = map(int, input().split())
matrix = [[randint(0, a) for i in range(n)] for j in range(m)]
And what does linear algebra and mathematics in general have to do with it? You create on a heap (or make a dynamic array by other means of the PL and its libraries) an array of the required dimension of the desired type and fill it with the values you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question