from typing import List


def rows_sum(square: List[List[int]], rotate: bool = False) -> int:
    """evaluate the sum of all rows in a double array

    :param square: the double array
    :param rotate: if true, swaps columns and rows
    :return: the sum of all rows
    """
    if rotate:
        square = list(zip(*reversed(square)))

    total = 0
    prev = sum(square[0])

    for i in range(len(square)):
        tmp = sum(square[i])

        if prev != tmp:
            raise ValueError('Not magic')

        prev = tmp
        total += tmp

    return total