Write a function called multiSum(A). This particular function should take in a N × M array, A, and return four results:
A 1 × M vector with the sum of the columns, A N × 1 vector with the sum of the rows, and Two numbers containing the sums of the two diagonals, the major diagonal first.
For example:
columnSum([1 2 3; 4 5 6; 7 8 9]) should return
[12 15 18], [6 15 24]', 15 and 15
columnSum([0 2 3; 4 0 6; 7 8 0]) should return
[11 10 9], [5 10 15]', 0 and 10
columnSum(eye[5,5]) should return
[1 1 1 1 1], [1 1 1 1 1]', 5 and 1
columnSum([]) should return [], [], 0 and 0Please give thumbs up, thanks

code:
function [rowSum,colSum,majorsum,minorsum]=multiSum(A)
[row,col]=size(A);
majorsum=0;
minorsum=0;
for i=1:row
rowSum(i)=sum(A(i,:));
colSum(i)=sum(A(:,i));
end
colSum=colSum';
for i=1:row
for j=1:col
if i==j
majorsum=majorsum+A(i,j);
end
if i+j==row+1
minorsum=minorsum+A(i,j);
end
end
end
end
Write a function called multiSum(A). This particular function should take in a N × M array,...
Use basic java for this after importing PrintWriter object You will make a simple Magic Square program for this Java Programming Assignment. Carefully read all the instructions before beginning to code. It is also required to turn in your pseudocode or a flowchart along with this program. Here are the instructions: At the beginning of the program, briefly describe to the user what a Magic Square Matrix is (described further on), and then allow them to enter “start” to begin...
Diagonal Difference HackerRank Pseudocode and C++: Given a square matrix, calculate the absolute difference between the sums of its diagonals. Function Description Complete the diagonalDifference function described below to calculate the absolute difference between diagonal sums. diagonalDifference( integer: a_size_rows, integer: a_size_cols, integer array: arr) Parameters: a_size_rows: number of rows in array a_size_cols: number of columns in array a: array of integers to process Returns: integer value that was calculated Constraints -100 < = elements of the matrix < = 100...
QUESTION 5: Write a C++ function called layers which takes an NxN integer array (for some constant N) and populates the entries 0..N2-1 as follows: The upper left entry (row-0, col-0) is 0. Subsequent numbers are assigned along Southwest-to-Northeast diagonals, layer-by-layer. For example, if N=4, your function would result in the following assignment to entries in the array: 0 2 5 9 1 4 8 12 3 7 11 14 6 10 13 15 (the individual “layers” are shown by...
Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array is randomly initialized (using Math.random()). Write a method to find the maximum value in this two dimensional array; Write a method to find the average value in the array; Write a method to count how many elements are smaller than average; Write a method to copy contents in a two-dimensional array to a one-dimensional array. The method will return this one-dimensional array. Method is...
(JAVA) Given an array of unique positive integers, write a function findSums that takes the array input and: 1. Creates a hashtable called “hashT” and inserts all the elements of the input array in the hashtable. 2. Finds pairs of elements in the hashtable whose sum is another element (sum) in the hashtable and print the pairs in the console. 3. Returns another hashtable names “sums” of those sum elements. For example: Input: [1,5,4,6,7,9] Output: [6,5,7,9] Explanation: 6 = 1...
Magic squares. An n × n matrix that is filled with the numbers 1, 2, 3, ..., n2 is a magic square if the sum ofthe elements in each row, in each column, and in the two diagonals is the same value. For example,16 3 2 135 10 11 89 6 7 124 15 14 1Write a program that reads in n2 values from the keyboard and tests whether they form a magic squarewhen arranged as a square matrix. You...
An m×n
array A
of real numbers is a Monge array if for all i,j,k,
and l
such that 1≤i<k≤m
and 1≤j<l≤n
, we have
>A[i,j]+a[k,l]≤A[i,l]+A[k,j]>
In other words, whenever we pick two rows and two columns of a
Monge array and consider the four elements at the intersections of
the rows and columns, the sum of the upper-left and lower-right
elements is less than or equal to the sum of the lower-left and
upper-right elements. For example, the following...
C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand how to traverse a two dimensional array Code and run a program that processes a two dimensional array Instructions: A magic square is a matrix (two dimensional arrays) in which the sum of each row, sum of each column, sum of the main diagonal, and sum of the reverse diagonal are all the same value. You are to code a program to determine...
Write a C++ function printArray(A, m, n) that prints a mxn two dimensional array A of integers, declared to be "int** A," to the standard output. Each of the rows should appear on a separate line. Your input will be as follows with the first two values being the number of rows and columns respectively. HINT: This is best done with one for-loop nested within another Sample 1/0 1: Input: 3 2 1 2 3 4 Ол 6 Output: 12...
Write a C function f such that … function f accepts, as input, … a two-dimensional array of integers in which each row has three columns the number of rows in the array function f returns the sum of the odd integers in the given array of integers and returns zero if there are no odd integers in the array COMPILER STACK TRACE None PROGRAM EXECUTION STACK TRACE None COMPILER COMMAND LINE ARGUMENTS -lm INPUT OF THE TEST CASE 1 #define NUM_ROWS 5...