submatrix

Maximum subarray of size HxW within a 2D matrix

心已入冬 提交于 2021-02-08 03:45:56
问题 Given a 2-dimensional array of positive integers, find the subrectangle of size HxW with the largest sum. The sum of a rectangle is the sum of all the elements in that rectangle. Input: A 2D array NxN with positive elements The HxW size of the subrectangle Output: The submatrix of HxW size with the largest sum of its elements. I've solved this using a brute-force method, however, I'm now looking for a better solution with better complexity (my brute-force method's complexity is O(n 6 )). 回答1:

Get a sub image using opencv Java

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 03:08:18
问题 I have already looked at how to get sub image by using OpenCV in java api, but this did not help I am curious how to create a sub image of a Mat image that I have loaded in from a file. When I run: crop = img.submat(405, 450, 280, 335); I get : OpenCV Error: Assertion failed (m.dims >= 2) in cv::Mat::Mat, file ..\..\..\..\opencv\modules\core\src\matrix.cpp, line 269 Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ..\..\..\..\opencv\modules\core\src\matrix

Get a sub image using opencv Java

时光总嘲笑我的痴心妄想 提交于 2021-01-28 01:08:46
问题 I have already looked at how to get sub image by using OpenCV in java api, but this did not help I am curious how to create a sub image of a Mat image that I have loaded in from a file. When I run: crop = img.submat(405, 450, 280, 335); I get : OpenCV Error: Assertion failed (m.dims >= 2) in cv::Mat::Mat, file ..\..\..\..\opencv\modules\core\src\matrix.cpp, line 269 Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ..\..\..\..\opencv\modules\core\src\matrix

Submatrix incorrectly defined in Scilab

自古美人都是妖i 提交于 2019-12-24 18:55:52
问题 I am given a morse potential to solve and to find its energy eigen values and vector by scilab. But i am having an issue as scilab is saying submatrix defined incorrectly. I am trying to see why my matrix is unable to be correct. I am new to this platform. De=4.618; b=18.118; x=0.1275; a=0.35; hc=197.327; mu=912847000; N=45; c=(De/(2*a*b)); d=exp(2*b*(x-a)); e=exp(2*b*x); i=exp(b*x); f=(2*De/(a*b)); g=((a*b)^(2)); h=(De*a*b/(2)); h=zeros(N,N); s=eye(N,N); for n=1:N h(n,n)=(((n*%pi*hc)^2)/(2

Manipulating sub matrices in R

梦想与她 提交于 2019-12-23 19:08:16
问题 Nh<-matrix(c(17,26,30,17,23, 17 ,24, 23), nrow=2, ncol=4); Nh Sh<-matrix(c(8.290133, 6.241174, 6.096808, 7.4449672, 6.894924, 7.692115, 4.540521, 7.409122), nrow=2, ncol=4); Sh NhSh<-as.matrix(Nh*Sh); NhSh rh<-c( 0.70710678, 0.40824829, 0.28867513, 0.22360680, 0.18257419, 0.15430335, 0.13363062, 0.11785113, 0.10540926, 0.09534626); rh pv <- c() for (j in 1:2) { for (i in 1:4) { pv <- rbind(pv, NhSh[j,i]*rh) } } pv row.names(pv) <- rep(c(1:2), each = 4) lst<-lapply(split(seq_len(nrow(pv)), as

How to print all square submatrices of square matrix in C?

◇◆丶佛笑我妖孽 提交于 2019-12-23 02:36:39
问题 Please, help me to find and print all square submatrices of square matrix from big to small square matrices in C programming language I wrote code that works wrong: int main() { int mtrx_size = 8; int mat[8][8] = { { 1, 2, 3, 4, 5, 6, 7, 8}, { 9,10,11,12,13,14,15,16}, {17,18,19,20,21,22,23,24}, {25,26,27,28,29,30,31,32}, {33,34,35,36,37,38,39,40}, {41,42,43,44,45,46,47,48}, {49,50,51,52,53,54,55,56}, {57,58,59,60,61,62,63,64} }; int i,j; int sub_mtrx_size; for(sub_mtrx_size = mtrx_size; sub

Better way to extract all the rows from a Matrix A that contain an element of a matrix B

二次信任 提交于 2019-12-22 18:42:47
问题 Matrix A is my starting matrix it holds the data logged from my MPU6050 and GPS on an SD Card (Latitude, Longitude, Time, Ax, Ay, Az, Gx,Gy,Gz). I calculated the standard deviation of Az for window size of 5 and identified all the elements that satisfy a condition (>threshold). Then in a matrix "large_windows" i stored the index of all the Az in the window that satisfy the condition. From matrix "large_windows" i calculated a new matrix B with all the rows from matrix A that contain the

find largest submatrix algorithm

徘徊边缘 提交于 2019-12-21 01:48:22
问题 I have an N*N matrix (N=2 to 10000) of numbers that may range from 0 to 1000. How can I find the largest (rectangular) submatrix that consists of the same number? Example: 1 2 3 4 5 -- -- -- -- -- 1 | 10 9 9 9 80 2 | 5 9 9 9 10 3 | 85 86 54 45 45 4 | 15 21 5 1 0 5 | 5 6 88 11 10 The output should be the area of the submatrix, followed by 1-based coordinates of its top left element. For the example, it would be (6, 2, 1) because there are six 9 s situated at column 2, row 1. 回答1: This is a

Finding sub matrix of a given matrix

一曲冷凌霜 提交于 2019-12-19 10:16:56
问题 i am trying to write an algorithm for finding a sub matrix in a given sub matrix. To solve this problem i had written the following code: public class SubMatTry { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int a[][] = { { 2, 3, 5, 7 }, { 5, 8, 3, 5 }, { 7, 6, 9, 2 }, { 3, 8, 5, 9 } }; int b[][] = { { 9, 2 }, { 5, 9 } }; int k = 0; int l = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { System.out.println("Element of a= " + a

Getting the submatrix with maximum sum?

混江龙づ霸主 提交于 2019-12-17 04:13:00
问题 Input : A 2-dimensional array NxN - Matrix - with positive and negative elements. Output : A submatrix of any size such that its summation is the maximum among all possible submatrices. Requirement : Algorithm complexity to be of O(N^3) History: With the help of the Algorithmist, Larry and a modification of Kadane's Algorithm, i managed to solve the problem partly which is determining the summation only - below in Java. Thanks to Ernesto who managed to solve the rest of the problem which is