# max(A, A') gives isless() error

**URL:** https://discourse.julialang.org/t/max-a-a-gives-isless-error/87165
**Category:** General Usage
**Created:** [September 12, 2022, 9:52pm UTC](https://discourse.julialang.org/t/max-a-a-gives-isless-error/87165 "2022-09-12T21:52:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![m\_shah2](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@m\_shah2](https://discourse.julialang.org/u/m_shah2)
#### Post date: [September 12, 2022, 9:52pm UTC](https://discourse.julialang.org/t/max-a-a-gives-isless-error/87165/1 "2022-09-12T21:52:51Z")

</div>

I am trying to generate a graph G by taking maxof SparseArrays.SparseMatrixCSC{Float64, Int64}  
and LinearAlgebra.Adjoint{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}

But it throws me an error when I do  
G = max(A, A’); # undirected version of graph

My original code is:

Pkg.add(“MAT”)  
Pkg.build(“MAT”)  
Pkg.add(“PyPlot”)  
Pkg.build(“PyPlot”)  
Pkg.add(“MatrixNetworks”)  
Pkg.build(“MatrixNetworks”)  
Pkg.add(“PyCall”)  
Pkg.build(“PyCall”)  
using MatrixNetworks  
using MAT  
using PyPlot  
using PyCall

data = matread(“data/neuronal.mat”);  
A = data[“A”];  
G = max(A, A’);

It runs fine till A, but throws error at G. Don’t know how to solve it.

I tried import Base: isless but no help.

This is the error:

MethodError: no method matching isless(::LinearAlgebra.Adjoint{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}, ::SparseArrays.SparseMatrixCSC{Float64, Int64})  
Closest candidates are:  
isless(::Any, ::Missing) at missing.jl:88  
isless(::Missing, ::Any) at missing.jl:87  
isless(::Any, ::PyObject) at C:\Users\Manish.julia\packages\PyCall\ygXW2\src\pyoperators.jl:76  
…

Stacktrace:  
[1] max(x::SparseArrays.SparseMatrixCSC{Float64, Int64}, y::LinearAlgebra.Adjoint{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}})  
@ Base .\operators.jl:480  
[2] top-level scope  
@ In[29]:1  
[3] eval  
@ .\boot.jl:368 [inlined]  
[4] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
@ Base .\loading.jl:1428

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [September 12, 2022, 10:02pm UTC](https://discourse.julialang.org/t/max-a-a-gives-isless-error/87165/2 "2022-09-12T22:02:16Z")

</div>

In order to calculate `max(A, A')` it must be possible to say which one is ‘greater’, and `isless` helps with that comparison.

But what is greater of `A` and `A'`? I don’t think there is any obvious answer to that question.

My guess is that you probably want to compare element-by-element, and to do that you can use broadcasting:

```julia
max.(A, A')

```

Notice the dot after `max`. This should return a matrix with pairwise comparisons of all elements.

Take a look at the broadcasting section of the manual for more information: [Multi-dimensional Arrays · The Julia Language](https://docs.julialang.org/en/v1/manual/arrays/#Broadcasting)

---

<div class="post-metadata">

### Author: ![m\_shah2](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@m\_shah2](https://discourse.julialang.org/u/m_shah2)
#### Post date: [September 12, 2022, 10:24pm UTC](https://discourse.julialang.org/t/max-a-a-gives-isless-error/87165/3 "2022-09-12T22:24:44Z")

</div>

This helped. Thanks a lot.
